Commit 88a91200 authored by Willem de Bruijn's avatar Willem de Bruijn Committed by Wentao Guan
Browse files

hexagon: fix using plain integer as NULL pointer warning in cmpxchg

stable inclusion
from stable-v6.6.76
commit 97517cba767177cb4b66e1b32010125b01e4a8af
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBW08Q

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=97517cba767177cb4b66e1b32010125b01e4a8af



--------------------------------

[ Upstream commit 8a20030038742b9915c6d811a4e6c14b126cafb4 ]

Sparse reports

    net/ipv4/inet_diag.c:1511:17: sparse: sparse: Using plain integer as NULL pointer

Due to this code calling cmpxchg on a non-integer type
struct inet_diag_handler *

    return !cmpxchg((const struct inet_diag_handler**)&inet_diag_table[type],
                    NULL, h) ? 0 : -EEXIST;

While hexagon's cmpxchg assigns an integer value to a variable of this
type.

    __typeof__(*(ptr)) __oldval = 0;

Update this assignment to cast 0 to the correct type.

The original issue is easily reproduced at head with the below block,
and is absent after this change.

    make LLVM=1 ARCH=hexagon defconfig
    make C=1 LLVM=1 ARCH=hexagon net/ipv4/inet_diag.o

Fixes: 99a70aa0 ("Hexagon: Add processor and system headers")
Reported-by: default avatarkernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202411091538.PGSTqUBi-lkp@intel.com/


Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
Tested-by: default avatarChristian Gmeiner <cgmeiner@igalia.com>
Link: https://lore.kernel.org/r/20241203221736.282020-1-willemdebruijn.kernel@gmail.com


Signed-off-by: default avatarBrian Cain <bcain@quicinc.com>
Signed-off-by: default avatarBrian Cain <brian.cain@oss.qualcomm.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
(cherry picked from commit 97517cba767177cb4b66e1b32010125b01e4a8af)
Signed-off-by: default avatarWentao Guan <guanwentao@uniontech.com>
parent c7bca03b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ __arch_xchg(unsigned long x, volatile void *ptr, int size)
	__typeof__(ptr) __ptr = (ptr);				\
	__typeof__(*(ptr)) __old = (old);			\
	__typeof__(*(ptr)) __new = (new);			\
	__typeof__(*(ptr)) __oldval = 0;			\
	__typeof__(*(ptr)) __oldval = (__typeof__(*(ptr))) 0;	\
								\
	asm volatile(						\
		"1:	%0 = memw_locked(%1);\n"		\