From fc63f82bc420d29f2f55f447f7a76b2a1503e4eb Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 5 Jul 2021 14:21:19 -0400 Subject: [PATCH] Fix: lttng: remove-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: I0bc71bf6c83df7d9d938cf93a12d5f6cf6d7ae36 --- src/bin/lttng/commands/remove_trigger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/lttng/commands/remove_trigger.c b/src/bin/lttng/commands/remove_trigger.c index 3c6e2b3f0..ce0e83ec7 100644 --- a/src/bin/lttng/commands/remove_trigger.c +++ b/src/bin/lttng/commands/remove_trigger.c @@ -227,7 +227,7 @@ error: end: /* Mi closing. */ - if (lttng_opt_mi) { + if (lttng_opt_mi && mi_writer) { /* Close output element. */ int mi_ret = mi_lttng_writer_close_element(mi_writer); if (mi_ret) { -- 2.34.1