]> git.lttng.org Git - userspace-rcu.git/commit
Avoid calling caa_container_of on NULL pointer in cds_lfht macros
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 22 Jun 2023 13:59:53 +0000 (09:59 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 29 Jun 2023 18:18:29 +0000 (14:18 -0400)
commit5b373e008426545e2dbe7c9b427281aa144b55ef
treea01958687bef02ef12fe0c739f301679f497b52e
parentc44ee106d4e3a06921c54d66a2f21b12a2dcd507
Avoid calling caa_container_of on NULL pointer in cds_lfht macros

The cds_lfht_for_each_entry and cds_lfht_for_each_entry_duplicate macros
would call caa_container_of() macro on NULL pointer.  This is not a
problem under normal circumstances as the check in the for loop fails
and the loop-statement is not called with invalid (pos) value.

However AddressSanitizer doesn't like that and complains about this:

    runtime error: applying non-zero offset 18446744073709551056 to null pointer

Move the cds_lfht_iter_get_node(iter) != NULL from the cond-expression
of the for loop into both init-clause and iteration-expression as
conditional operator and check for (pos) value in the cond-expression
instead. Introduce the cds_lfht_entry() macro to eliminate code
duplication.

Reported-by: Ondřej Surý <ondrej@sury.org>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I9969c1e0bc0eefc8c90c0d8f17b2927f6a4feb2a
include/urcu/rculfhash.h
This page took 0.029115 seconds and 4 git commands to generate.