* [PATCH] hexagon: fix using plain integer as NULL pointer warning in cmpxchg
@ 2024-12-03 22:17 Willem de Bruijn
2025-01-07 10:17 ` Christian Gmeiner
0 siblings, 1 reply; 4+ messages in thread
From: Willem de Bruijn @ 2024-12-03 22:17 UTC (permalink / raw)
To: linux-hexagon
Cc: bcain, linux-kernel, dhowells, edumazet, Willem de Bruijn,
kernel test robot
From: Willem de Bruijn <willemb@google.com>
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>
---
arch/hexagon/include/asm/cmpxchg.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/hexagon/include/asm/cmpxchg.h b/arch/hexagon/include/asm/cmpxchg.h
index bf6cf5579cf4..9c58fb81f7fd 100644
--- a/arch/hexagon/include/asm/cmpxchg.h
+++ b/arch/hexagon/include/asm/cmpxchg.h
@@ -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" \
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] hexagon: fix using plain integer as NULL pointer warning in cmpxchg
2024-12-03 22:17 [PATCH] hexagon: fix using plain integer as NULL pointer warning in cmpxchg Willem de Bruijn
@ 2025-01-07 10:17 ` Christian Gmeiner
2025-01-26 22:59 ` Maíra Canal
0 siblings, 1 reply; 4+ messages in thread
From: Christian Gmeiner @ 2025-01-07 10:17 UTC (permalink / raw)
To: Willem de Bruijn
Cc: linux-hexagon, bcain, linux-kernel, dhowells, edumazet,
Willem de Bruijn, kernel test robot, Maíra Canal
Hi Willem,
>
> From: Willem de Bruijn <willemb@google.com>
>
> 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>
Closes: https://lore.kernel.org/oe-kbuild-all/202501031246.AD8Jjze0-lkp@intel.com/
Tested-by: Christian Gmeiner <cgmeiner@igalia.com>
> ---
> arch/hexagon/include/asm/cmpxchg.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/hexagon/include/asm/cmpxchg.h b/arch/hexagon/include/asm/cmpxchg.h
> index bf6cf5579cf4..9c58fb81f7fd 100644
> --- a/arch/hexagon/include/asm/cmpxchg.h
> +++ b/arch/hexagon/include/asm/cmpxchg.h
> @@ -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" \
> --
> 2.47.0.338.g60cca15819-goog
>
>
--
greets
--
Christian Gmeiner, MSc
https://christian-gmeiner.info/privacypolicy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hexagon: fix using plain integer as NULL pointer warning in cmpxchg
2025-01-07 10:17 ` Christian Gmeiner
@ 2025-01-26 22:59 ` Maíra Canal
2025-01-27 16:21 ` Brian Cain
0 siblings, 1 reply; 4+ messages in thread
From: Maíra Canal @ 2025-01-26 22:59 UTC (permalink / raw)
To: Christian Gmeiner, Willem de Bruijn
Cc: linux-hexagon, bcain, linux-kernel, dhowells, edumazet,
Willem de Bruijn, kernel test robot, mcanal
Hi Brian,
Do you have an estimate for when this patch will be picked? We are
getting build reports from Hexagon in the V3D GPU driver [1].
[1]
https://lore.kernel.org/oe-kbuild-all/202501031246.AD8Jjze0-lkp@intel.com/
Best Regards,
- Maíra
On 07/01/25 07:17, Christian Gmeiner wrote:
> Hi Willem,
>
>>
>> From: Willem de Bruijn <willemb@google.com>
>>
>> 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>
>
> Closes: https://lore.kernel.org/oe-kbuild-all/202501031246.AD8Jjze0-lkp@intel.com/
> Tested-by: Christian Gmeiner <cgmeiner@igalia.com>
>
>> ---
>> arch/hexagon/include/asm/cmpxchg.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/hexagon/include/asm/cmpxchg.h b/arch/hexagon/include/asm/cmpxchg.h
>> index bf6cf5579cf4..9c58fb81f7fd 100644
>> --- a/arch/hexagon/include/asm/cmpxchg.h
>> +++ b/arch/hexagon/include/asm/cmpxchg.h
>> @@ -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" \
>> --
>> 2.47.0.338.g60cca15819-goog
>>
>>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] hexagon: fix using plain integer as NULL pointer warning in cmpxchg
2025-01-26 22:59 ` Maíra Canal
@ 2025-01-27 16:21 ` Brian Cain
0 siblings, 0 replies; 4+ messages in thread
From: Brian Cain @ 2025-01-27 16:21 UTC (permalink / raw)
To: Maíra Canal, Christian Gmeiner, Willem de Bruijn
Cc: linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org,
dhowells@redhat.com, edumazet@google.com, Willem de Bruijn,
kernel test robot
> -----Original Message-----
> From: Maíra Canal <mcanal@igalia.com>
> Sent: Sunday, January 26, 2025 4:59 PM
> To: Christian Gmeiner <christian.gmeiner@gmail.com>; Willem de Bruijn
> <willemdebruijn.kernel@gmail.com>
> Cc: linux-hexagon@vger.kernel.org; Brian Cain <bcain@quicinc.com>; linux-
> kernel@vger.kernel.org; dhowells@redhat.com; edumazet@google.com;
> Willem de Bruijn <willemb@google.com>; kernel test robot <lkp@intel.com>;
> mcanal@igalia.com
> Subject: Re: [PATCH] hexagon: fix using plain integer as NULL pointer warning
> in cmpxchg
>
> WARNING: This email originated from outside of Qualcomm. Please be wary of
> any links or attachments, and do not enable macros.
>
> Hi Brian,
>
> Do you have an estimate for when this patch will be picked? We are
> getting build reports from Hexagon in the V3D GPU driver [1].
Sorry for the delay. I will work on it this week, Maíra.
> [1]
> https://lore.kernel.org/oe-kbuild-all/202501031246.AD8Jjze0-lkp@intel.com/
>
> Best Regards,
> - Maíra
>
> On 07/01/25 07:17, Christian Gmeiner wrote:
> > Hi Willem,
> >
> >>
> >> From: Willem de Bruijn <willemb@google.com>
> >>
> >> 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>
> >
> > Closes: https://lore.kernel.org/oe-kbuild-all/202501031246.AD8Jjze0-
> lkp@intel.com/
> > Tested-by: Christian Gmeiner <cgmeiner@igalia.com>
> >
> >> ---
> >> arch/hexagon/include/asm/cmpxchg.h | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/arch/hexagon/include/asm/cmpxchg.h
> b/arch/hexagon/include/asm/cmpxchg.h
> >> index bf6cf5579cf4..9c58fb81f7fd 100644
> >> --- a/arch/hexagon/include/asm/cmpxchg.h
> >> +++ b/arch/hexagon/include/asm/cmpxchg.h
> >> @@ -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" \
> >> --
> >> 2.47.0.338.g60cca15819-goog
> >>
> >>
> >
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-27 16:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-03 22:17 [PATCH] hexagon: fix using plain integer as NULL pointer warning in cmpxchg Willem de Bruijn
2025-01-07 10:17 ` Christian Gmeiner
2025-01-26 22:59 ` Maíra Canal
2025-01-27 16:21 ` Brian Cain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).