From: Jérémie Galarneau Date: Mon, 22 Mar 2021 17:00:09 +0000 (-0400) Subject: Fix: lttng-sessiond: kernel: leak of event notifier rule X-Git-Tag: v2.13.0-rc1~201 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=e8b1187d0ff0323106069738b2fff5c9e5a7d9bb Fix: lttng-sessiond: kernel: leak of event notifier rule 1445768 Resource leak The system resource will not be reclaimed and reused, reducing the future availability of the resource. In kernel_create_event_notifier_rule: Leak of memory or pointers to system resources (CWE-404) Reported by: Coverity Scan Signed-off-by: Jérémie Galarneau Change-Id: I58862b3b38c7e61806e0047840bf68619273db49 --- diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index bad864db0..03a358a0d 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -2408,7 +2408,7 @@ static enum lttng_error_code kernel_create_event_notifier_rule( if (capture_bytecode == NULL) { ERR("Unexpected NULL capture bytecode on condition"); error_code_ret = LTTNG_ERR_KERN_ENABLE_FAIL; - goto error; + goto capture_error; } ret = kernctl_capture(event_notifier_rule->fd, capture_bytecode); @@ -2416,7 +2416,7 @@ static enum lttng_error_code kernel_create_event_notifier_rule( ERR("Failed to set capture bytecode on event notifier rule fd: fd = %d", event_notifier_rule->fd); error_code_ret = LTTNG_ERR_KERN_ENABLE_FAIL; - goto error; + goto capture_error; } } @@ -2446,6 +2446,7 @@ static enum lttng_error_code kernel_create_event_notifier_rule( return LTTNG_OK; +capture_error: add_callsite_error: enable_error: set_cloexec_error: