From 44d0e2f1fb3af20af90a224a2f459c228b75b596 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 7 Apr 2021 12:01:33 -0400 Subject: [PATCH] Fix: sessiond: error accounting: unchecked lttng_ht_del return value MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit There is no reason for this deletion to fail; assert that it succeeds to detect any internal error. 1451556 Unchecked return value If the function returns an error value, the error value may be mistaken for a normal value. In event_notifier_error_accounting_unregister_event_notifier: Value returned from a function is not checked for errors before being used (CWE-252) Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau Change-Id: I3d0f8995608ac96cd3c94b5e92c4459fff592702 --- src/bin/lttng-sessiond/event-notifier-error-accounting.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bin/lttng-sessiond/event-notifier-error-accounting.c b/src/bin/lttng-sessiond/event-notifier-error-accounting.c index 6837fe8f3..035f3a036 100644 --- a/src/bin/lttng-sessiond/event-notifier-error-accounting.c +++ b/src/bin/lttng-sessiond/event-notifier-error-accounting.c @@ -1003,6 +1003,7 @@ void event_notifier_error_accounting_unregister_event_notifier( lttng_ht_lookup(error_counter_indexes_ht, &tracer_token, &iter); node = lttng_ht_iter_get_node_u64(&iter); if (node) { + int del_ret; struct index_ht_entry *index_entry = caa_container_of( node, typeof(*index_entry), node); enum lttng_index_allocator_status index_alloc_status; @@ -1023,7 +1024,8 @@ void event_notifier_error_accounting_unregister_event_notifier( /* Don't exit, perform the rest of the clean-up. */ } - lttng_ht_del(error_counter_indexes_ht, &iter); + del_ret = lttng_ht_del(error_counter_indexes_ht, &iter); + assert(!del_ret); call_rcu(&index_entry->rcu_head, free_index_ht_entry); } -- 2.34.1