llist: clang: introduce member_address_is_nonnull()
authorAlexander Potapenko <glider@google.com>
Wed, 19 Jul 2017 18:27:30 +0000 (20:27 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 8 Apr 2018 10:12:50 +0000 (12:12 +0200)
commitecd508abb0fa6716a6b397e9bf9e3efbfa4c5864
tree3f194c6a66f49e6ddaa3a87713e0635f64ce1343
parent24382a60331d6be571b09eb2165815dbab2457cc
llist: clang: introduce member_address_is_nonnull()

commit beaec533fc2701a28a4d667f67c9f59c6e4e0d13 upstream.

Currently llist_for_each_entry() and llist_for_each_entry_safe() iterate
until &pos->member != NULL.  But when building the kernel with Clang,
the compiler assumes &pos->member cannot be NULL if the member's offset
is greater than 0 (which would be equivalent to the object being
non-contiguous in memory).  Therefore the loop condition is always true,
and the loops become infinite.

To work around this, introduce the member_address_is_nonnull() macro,
which casts object pointer to uintptr_t, thus letting the member pointer
to be NULL.

Signed-off-by: Alexander Potapenko <glider@google.com>
Tested-by: Sodagudi Prasad <psodagud@codeaurora.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/llist.h