From: Jérémie Galarneau Date: Mon, 5 Jul 2021 18:21:19 +0000 (-0400) Subject: Fix: lttng: remove-trigger: null dereference on MI initialization error X-Git-Tag: v2.13.0-rc3~17 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9ec21c2a12dc7db110ddc78b58078c7273129a81;p=lttng-tools.git Fix: lttng: remove-trigger: null dereference on MI initialization error 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 --- 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) {