From 294851b040ddfb224f906015e87d6cfe41952808 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Sat, 6 May 2017 14:34:42 -0400 Subject: [PATCH] Fix: dereference before null check of channel attributes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reported-by: Coverity Scan CID 1374802 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking attr suggests that it may be null, but it has already been dereferenced on all paths leading to the check. Signed-off-by: Jérémie Galarneau --- src/lib/lttng-ctl/lttng-ctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 469fffa98..6bd3f80ec 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -2047,14 +2047,14 @@ int lttng_calibrate(struct lttng_handle *handle, void lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr) { - struct lttng_channel_extended *extended = - (struct lttng_channel_extended *) attr->extended.ptr; + struct lttng_channel_extended *extended; /* Safety check */ if (attr == NULL || domain == NULL) { return; } + extended = (struct lttng_channel_extended *) attr->extended.ptr; memset(attr, 0, sizeof(struct lttng_channel_attr)); /* Same for all domains. */ -- 2.34.1