From: Jérémie Galarneau Date: Sat, 6 May 2017 18:34:42 +0000 (-0400) Subject: Fix: dereference before null check of channel attributes X-Git-Tag: v2.11.0-rc1~609 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=294851b040ddfb224f906015e87d6cfe41952808;p=lttng-tools.git Fix: dereference before null check of channel attributes 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 --- 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. */