linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtlwifi: rtl8192cu: remove pointless memcpy
@ 2018-02-09 13:24 Arnd Bergmann
  2018-02-09 16:16 ` Joe Perches
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Arnd Bergmann @ 2018-02-09 13:24 UTC (permalink / raw)
  To: Ping-Ke Shih
  Cc: Arnd Bergmann, Kalle Valo, Johannes Berg, linux-wireless, netdev,
	linux-kernel

gcc-8 points out that source and destination of the memcpy() are
always the same pointer, so the effect of memcpy() is undefined
here (its arguments must not overlap):

drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c: In function '_rtl_rx_process':
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c:430:2: error: 'memcpy' source argument is the same as destination [-Werror=restrict]

Most likely this is harmless, but it's easy to just remove the
line and get rid of the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
index ac4a82de40c7..9ab56827124e 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
@@ -427,7 +427,6 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
 		 (u32)hdr->addr1[0], (u32)hdr->addr1[1],
 		 (u32)hdr->addr1[2], (u32)hdr->addr1[3],
 		 (u32)hdr->addr1[4], (u32)hdr->addr1[5]);
-	memcpy(IEEE80211_SKB_RXCB(skb), rx_status, sizeof(*rx_status));
 	ieee80211_rx(hw, skb);
 }
 
-- 
2.9.0

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

* Re: [PATCH] rtlwifi: rtl8192cu: remove pointless memcpy
  2018-02-09 13:24 [PATCH] rtlwifi: rtl8192cu: remove pointless memcpy Arnd Bergmann
@ 2018-02-09 16:16 ` Joe Perches
  2018-02-09 16:44 ` Larry Finger
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Joe Perches @ 2018-02-09 16:16 UTC (permalink / raw)
  To: Arnd Bergmann, Ping-Ke Shih
  Cc: Kalle Valo, Johannes Berg, linux-wireless, netdev, linux-kernel

On Fri, 2018-02-09 at 14:24 +0100, Arnd Bergmann wrote:
> gcc-8 points out that source and destination of the memcpy() are
> always the same pointer, so the effect of memcpy() is undefined
> here (its arguments must not overlap):
> 
> drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c: In function '_rtl_rx_process':
> drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c:430:2: error: 'memcpy' source argument is the same as destination [-Werror=restrict]
> 
> Most likely this is harmless, but it's easy to just remove the
> line and get rid of the warning.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> index ac4a82de40c7..9ab56827124e 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> @@ -427,7 +427,6 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
>  		 (u32)hdr->addr1[0], (u32)hdr->addr1[1],
>  		 (u32)hdr->addr1[2], (u32)hdr->addr1[3],
>  		 (u32)hdr->addr1[4], (u32)hdr->addr1[5]);
> -	memcpy(IEEE80211_SKB_RXCB(skb), rx_status, sizeof(*rx_status));
>  	ieee80211_rx(hw, skb);
>  }

trivia:

The RT_TRACE above this should probably use %pM too.
Not submitted as it would just cause a conflict.

---

 drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
index ac4a82de40c7..61da667ed8ba 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
@@ -422,11 +422,8 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
 	if (ieee80211_is_data(fc))
 		RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Got data frame\n");
 	RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
-		 "Fram: fc = 0x%X addr1 = 0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X\n",
-		 fc,
-		 (u32)hdr->addr1[0], (u32)hdr->addr1[1],
-		 (u32)hdr->addr1[2], (u32)hdr->addr1[3],
-		 (u32)hdr->addr1[4], (u32)hdr->addr1[5]);
+		 "Fram: fc = 0x%X addr1 = %pM\n",
+		 fc, hdr->addr1);
 	memcpy(IEEE80211_SKB_RXCB(skb), rx_status, sizeof(*rx_status));
 	ieee80211_rx(hw, skb);
 }

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

* Re: [PATCH] rtlwifi: rtl8192cu: remove pointless memcpy
  2018-02-09 13:24 [PATCH] rtlwifi: rtl8192cu: remove pointless memcpy Arnd Bergmann
  2018-02-09 16:16 ` Joe Perches
@ 2018-02-09 16:44 ` Larry Finger
  2018-02-09 16:56 ` Larry Finger
  2018-02-27 16:18 ` Kalle Valo
  3 siblings, 0 replies; 5+ messages in thread
From: Larry Finger @ 2018-02-09 16:44 UTC (permalink / raw)
  To: Arnd Bergmann, Ping-Ke Shih
  Cc: Kalle Valo, Johannes Berg, linux-wireless, netdev, linux-kernel

On 02/09/2018 07:24 AM, Arnd Bergmann wrote:
> gcc-8 points out that source and destination of the memcpy() are
> always the same pointer, so the effect of memcpy() is undefined
> here (its arguments must not overlap):
> 
> drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c: In function '_rtl_rx_process':
> drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c:430:2: error: 'memcpy' source argument is the same as destination [-Werror=restrict]
> 
> Most likely this is harmless, but it's easy to just remove the
> line and get rid of the warning.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> index ac4a82de40c7..9ab56827124e 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> @@ -427,7 +427,6 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
>   		 (u32)hdr->addr1[0], (u32)hdr->addr1[1],
>   		 (u32)hdr->addr1[2], (u32)hdr->addr1[3],
>   		 (u32)hdr->addr1[4], (u32)hdr->addr1[5]);
> -	memcpy(IEEE80211_SKB_RXCB(skb), rx_status, sizeof(*rx_status));
>   	ieee80211_rx(hw, skb);
>   }

No, the warning is pointing to the wrong place. The routine in question does the 
following:

1. Loads the rx_status struct from skb->cb.
2. Overwrites the contents with 0.
3. Fills various members of the struct.
4. Writes the revised struct back into skb->cb.

Thus eliminating step 4 negates all the things done in step 3, and is wrong. The 
correct fix is to change step 1 to create a NULL-filled rx_status struct, and 
eliminate step 2.

NACK.

Larry

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

* Re: [PATCH] rtlwifi: rtl8192cu: remove pointless memcpy
  2018-02-09 13:24 [PATCH] rtlwifi: rtl8192cu: remove pointless memcpy Arnd Bergmann
  2018-02-09 16:16 ` Joe Perches
  2018-02-09 16:44 ` Larry Finger
@ 2018-02-09 16:56 ` Larry Finger
  2018-02-27 16:18 ` Kalle Valo
  3 siblings, 0 replies; 5+ messages in thread
From: Larry Finger @ 2018-02-09 16:56 UTC (permalink / raw)
  To: Arnd Bergmann, Ping-Ke Shih
  Cc: Kalle Valo, Johannes Berg, linux-wireless, netdev, linux-kernel

On 02/09/2018 07:24 AM, Arnd Bergmann wrote:
> gcc-8 points out that source and destination of the memcpy() are
> always the same pointer, so the effect of memcpy() is undefined
> here (its arguments must not overlap):
> 
> drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c: In function '_rtl_rx_process':
> drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c:430:2: error: 'memcpy' source argument is the same as destination [-Werror=restrict]
> 
> Most likely this is harmless, but it's easy to just remove the
> line and get rid of the warning.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> index ac4a82de40c7..9ab56827124e 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> @@ -427,7 +427,6 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
>   		 (u32)hdr->addr1[0], (u32)hdr->addr1[1],
>   		 (u32)hdr->addr1[2], (u32)hdr->addr1[3],
>   		 (u32)hdr->addr1[4], (u32)hdr->addr1[5]);
> -	memcpy(IEEE80211_SKB_RXCB(skb), rx_status, sizeof(*rx_status));
>   	ieee80211_rx(hw, skb);
>   }

Argh. Once again I got tripped up on pointers. Yes, this patch is correct.

Acked-by: Larry Finger <Larry.Finger@lwfinger.net>

Sorry about the noise.

Larry

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

* Re: rtlwifi: rtl8192cu: remove pointless memcpy
  2018-02-09 13:24 [PATCH] rtlwifi: rtl8192cu: remove pointless memcpy Arnd Bergmann
                   ` (2 preceding siblings ...)
  2018-02-09 16:56 ` Larry Finger
@ 2018-02-27 16:18 ` Kalle Valo
  3 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2018-02-27 16:18 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Ping-Ke Shih, Arnd Bergmann, Johannes Berg, linux-wireless,
	netdev, linux-kernel

Arnd Bergmann <arnd@arndb.de> wrote:

> gcc-8 points out that source and destination of the memcpy() are
> always the same pointer, so the effect of memcpy() is undefined
> here (its arguments must not overlap):
> 
> drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c: In function '_rtl_rx_process':
> drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c:430:2: error: 'memcpy' source argument is the same as destination [-Werror=restrict]
> 
> Most likely this is harmless, but it's easy to just remove the
> line and get rid of the warning.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Acked-by: Larry Finger <Larry.Finger@lwfinger.net>

Patch applied to wireless-drivers-next.git, thanks.

dcdd54c2bcae rtlwifi: rtl8192cu: remove pointless memcpy

-- 
https://patchwork.kernel.org/patch/10208979/

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

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

end of thread, other threads:[~2018-02-27 16:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-09 13:24 [PATCH] rtlwifi: rtl8192cu: remove pointless memcpy Arnd Bergmann
2018-02-09 16:16 ` Joe Perches
2018-02-09 16:44 ` Larry Finger
2018-02-09 16:56 ` Larry Finger
2018-02-27 16:18 ` Kalle Valo

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).