From 4627fa543a2eb65d7b046b18e015986f45de5835 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 5 Jul 2021 14:16:00 -0400 Subject: [PATCH] Fix: lttng: add-trigger: null dereference on MI initialization error MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Failures to create an MI writer instance will result in a dereference of the MI writer when attempting to close the command's output element. 1457842 Dereference after null check Either the check against null is unnecessary, or there may be a null pointer dereference. In cmd_add_trigger: Pointer is checked against null but then dereferenced anyway (CWE-476) Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau Change-Id: I98b844d2f1c7abd43bd42ee472759de57b34484e --- src/bin/lttng/commands/add_trigger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/lttng/commands/add_trigger.c b/src/bin/lttng/commands/add_trigger.c index e4111eba0..00f8f47e3 100644 --- a/src/bin/lttng/commands/add_trigger.c +++ b/src/bin/lttng/commands/add_trigger.c @@ -2428,7 +2428,7 @@ error: end: /* Mi closing. */ - if (lttng_opt_mi) { + if (lttng_opt_mi && mi_writer) { int mi_ret; /* Close output element. */ -- 2.34.1