All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mwifiex: avoid null-pointer-subtraction warning
@ 2021-09-27 12:16 Arnd Bergmann
  2021-09-28  6:43   ` Kalle Valo
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Arnd Bergmann @ 2021-09-27 12:16 UTC (permalink / raw)
  To: Amitkumar Karwar, Ganapathi Bhat, Sharvari Harisangam,
	Xinming Hu, Kalle Valo
  Cc: Arnd Bergmann, David S. Miller, Jakub Kicinski,
	Nathan Chancellor, Nick Desaulniers, linux-wireless, netdev,
	linux-kernel, llvm

From: Arnd Bergmann <arnd@arndb.de>

clang complains about some NULL pointer arithmetic in this driver:

drivers/net/wireless/marvell/mwifiex/sta_tx.c:65:59: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
        pad = ((void *)skb->data - (sizeof(*local_tx_pd) + hroom)-
                                                                 ^
drivers/net/wireless/marvell/mwifiex/uap_txrx.c:478:53: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
        pad = ((void *)skb->data - (sizeof(*txpd) + hroom) - NULL) &

Rework that expression to do the same thing using a uintptr_t.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/wireless/marvell/mwifiex/sta_tx.c   | 4 ++--
 drivers/net/wireless/marvell/mwifiex/uap_txrx.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/sta_tx.c b/drivers/net/wireless/marvell/mwifiex/sta_tx.c
index 241305377e20..a9b5eb992220 100644
--- a/drivers/net/wireless/marvell/mwifiex/sta_tx.c
+++ b/drivers/net/wireless/marvell/mwifiex/sta_tx.c
@@ -62,8 +62,8 @@ void *mwifiex_process_sta_txpd(struct mwifiex_private *priv,
 
 	pkt_type = mwifiex_is_skb_mgmt_frame(skb) ? PKT_TYPE_MGMT : 0;
 
-	pad = ((void *)skb->data - (sizeof(*local_tx_pd) + hroom)-
-			 NULL) & (MWIFIEX_DMA_ALIGN_SZ - 1);
+	pad = ((uintptr_t)skb->data - (sizeof(*local_tx_pd) + hroom)) &
+	       (MWIFIEX_DMA_ALIGN_SZ - 1);
 	skb_push(skb, sizeof(*local_tx_pd) + pad);
 
 	local_tx_pd = (struct txpd *) skb->data;
diff --git a/drivers/net/wireless/marvell/mwifiex/uap_txrx.c b/drivers/net/wireless/marvell/mwifiex/uap_txrx.c
index 9bbdb8dfce62..245ff644f81e 100644
--- a/drivers/net/wireless/marvell/mwifiex/uap_txrx.c
+++ b/drivers/net/wireless/marvell/mwifiex/uap_txrx.c
@@ -475,8 +475,8 @@ void *mwifiex_process_uap_txpd(struct mwifiex_private *priv,
 
 	pkt_type = mwifiex_is_skb_mgmt_frame(skb) ? PKT_TYPE_MGMT : 0;
 
-	pad = ((void *)skb->data - (sizeof(*txpd) + hroom) - NULL) &
-			(MWIFIEX_DMA_ALIGN_SZ - 1);
+	pad = ((uintptr_t)skb->data - (sizeof(*txpd) + hroom)) &
+	       (MWIFIEX_DMA_ALIGN_SZ - 1);
 
 	skb_push(skb, sizeof(*txpd) + pad);
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mwifiex: avoid null-pointer-subtraction warning
  2021-09-27 12:16 [PATCH] mwifiex: avoid null-pointer-subtraction warning Arnd Bergmann
@ 2021-09-28  6:43   ` Kalle Valo
  2021-09-28 14:42 ` Kalle Valo
  2021-09-28 14:42 ` Kalle Valo
  2 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2021-09-28  6:43 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Amitkumar Karwar, Ganapathi Bhat, Sharvari Harisangam,
	Xinming Hu, Arnd Bergmann, David S. Miller, Jakub Kicinski,
	Nathan Chancellor, Nick Desaulniers, linux-wireless, netdev,
	linux-kernel, llvm

Arnd Bergmann <arnd@kernel.org> writes:

> From: Arnd Bergmann <arnd@arndb.de>
>
> clang complains about some NULL pointer arithmetic in this driver:
>
> drivers/net/wireless/marvell/mwifiex/sta_tx.c:65:59: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
>         pad = ((void *)skb->data - (sizeof(*local_tx_pd) + hroom)-
>                                                                  ^
> drivers/net/wireless/marvell/mwifiex/uap_txrx.c:478:53: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
>         pad = ((void *)skb->data - (sizeof(*txpd) + hroom) - NULL) &
>
> Rework that expression to do the same thing using a uintptr_t.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

I'll queue this to v5.15.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mwifiex: avoid null-pointer-subtraction warning
@ 2021-09-28  6:43   ` Kalle Valo
  0 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2021-09-28  6:43 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Amitkumar Karwar, Ganapathi Bhat, Sharvari Harisangam,
	Xinming Hu, Arnd Bergmann, David S. Miller, Jakub Kicinski,
	Nathan Chancellor, Nick Desaulniers, linux-wireless, netdev,
	linux-kernel, llvm

Arnd Bergmann <arnd@kernel.org> writes:

> From: Arnd Bergmann <arnd@arndb.de>
>
> clang complains about some NULL pointer arithmetic in this driver:
>
> drivers/net/wireless/marvell/mwifiex/sta_tx.c:65:59: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
>         pad = ((void *)skb->data - (sizeof(*local_tx_pd) + hroom)-
>                                                                  ^
> drivers/net/wireless/marvell/mwifiex/uap_txrx.c:478:53: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
>         pad = ((void *)skb->data - (sizeof(*txpd) + hroom) - NULL) &
>
> Rework that expression to do the same thing using a uintptr_t.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

I'll queue this to v5.15.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mwifiex: avoid null-pointer-subtraction warning
  2021-09-27 12:16 [PATCH] mwifiex: avoid null-pointer-subtraction warning Arnd Bergmann
  2021-09-28  6:43   ` Kalle Valo
  2021-09-28 14:42 ` Kalle Valo
@ 2021-09-28 14:42 ` Kalle Valo
  2 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2021-09-28 14:42 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Amitkumar Karwar, Ganapathi Bhat, Sharvari Harisangam,
	Xinming Hu, Arnd Bergmann, David S. Miller, Jakub Kicinski,
	Nathan Chancellor, Nick Desaulniers, linux-wireless, netdev,
	linux-kernel, llvm

Arnd Bergmann <arnd@kernel.org> wrote:

> From: Arnd Bergmann <arnd@arndb.de>
> 
> clang complains about some NULL pointer arithmetic in this driver:
> 
> drivers/net/wireless/marvell/mwifiex/sta_tx.c:65:59: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
>         pad = ((void *)skb->data - (sizeof(*local_tx_pd) + hroom)-
>                                                                  ^
> drivers/net/wireless/marvell/mwifiex/uap_txrx.c:478:53: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
>         pad = ((void *)skb->data - (sizeof(*txpd) + hroom) - NULL) &
> 
> Rework that expression to do the same thing using a uintptr_t.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Patch applied to wireless-drivers.git, thanks.

603a1621caa0 mwifiex: avoid null-pointer-subtraction warning

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20210927121656.940304-1-arnd@kernel.org/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mwifiex: avoid null-pointer-subtraction warning
  2021-09-27 12:16 [PATCH] mwifiex: avoid null-pointer-subtraction warning Arnd Bergmann
  2021-09-28  6:43   ` Kalle Valo
@ 2021-09-28 14:42 ` Kalle Valo
  2021-09-28 14:42 ` Kalle Valo
  2 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2021-09-28 14:42 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Amitkumar Karwar, Ganapathi Bhat, Sharvari Harisangam,
	Xinming Hu, Arnd Bergmann, David S. Miller, Jakub Kicinski,
	Nathan Chancellor, Nick Desaulniers, linux-wireless, netdev,
	linux-kernel, llvm

Arnd Bergmann <arnd@kernel.org> wrote:

> From: Arnd Bergmann <arnd@arndb.de>
> 
> clang complains about some NULL pointer arithmetic in this driver:
> 
> drivers/net/wireless/marvell/mwifiex/sta_tx.c:65:59: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
>         pad = ((void *)skb->data - (sizeof(*local_tx_pd) + hroom)-
>                                                                  ^
> drivers/net/wireless/marvell/mwifiex/uap_txrx.c:478:53: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
>         pad = ((void *)skb->data - (sizeof(*txpd) + hroom) - NULL) &
> 
> Rework that expression to do the same thing using a uintptr_t.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Patch applied to wireless-drivers.git, thanks.

603a1621caa0 mwifiex: avoid null-pointer-subtraction warning

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20210927121656.940304-1-arnd@kernel.org/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-28 14:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 12:16 [PATCH] mwifiex: avoid null-pointer-subtraction warning Arnd Bergmann
2021-09-28  6:43 ` Kalle Valo
2021-09-28  6:43   ` Kalle Valo
2021-09-28 14:42 ` Kalle Valo
2021-09-28 14:42 ` Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.