]> www.infradead.org Git - users/dwmw2/linux.git/commit
hexagon: fix using plain integer as NULL pointer warning in cmpxchg
authorWillem de Bruijn <willemb@google.com>
Tue, 3 Dec 2024 22:17:34 +0000 (17:17 -0500)
committerBrian Cain <brian.cain@oss.qualcomm.com>
Fri, 31 Jan 2025 02:44:54 +0000 (18:44 -0800)
commit8a20030038742b9915c6d811a4e6c14b126cafb4
tree60189833d2d3a60a688d57c36e0879136d53b312
parentcd45f362fc1f2d81fa69a19e7f8eca058db3e320
hexagon: fix using plain integer as NULL pointer warning in cmpxchg

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: 99a70aa051d2 ("Hexagon: Add processor and system headers")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202411091538.PGSTqUBi-lkp@intel.com/
Signed-off-by: Willem de Bruijn <willemb@google.com>
Tested-by: Christian Gmeiner <cgmeiner@igalia.com>
Link: https://lore.kernel.org/r/20241203221736.282020-1-willemdebruijn.kernel@gmail.com
Signed-off-by: Brian Cain <bcain@quicinc.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
arch/hexagon/include/asm/cmpxchg.h