net: qlge: use memmove instead of skb_copy_to_linear_data

Message ID 20180202154603.1617656-1-arnd@arndb.de
State New
Headers show
Series
  • net: qlge: use memmove instead of skb_copy_to_linear_data
Related show

Commit Message

Arnd Bergmann Feb. 2, 2018, 3:45 p.m.
gcc-8 points out that the skb_copy_to_linear_data() argument points to
the skb itself, which makes it run into a problem with overlapping
memcpy arguments:

In file included from include/linux/ip.h:20,
                 from drivers/net/ethernet/qlogic/qlge/qlge_main.c:26:
drivers/net/ethernet/qlogic/qlge/qlge_main.c: In function 'ql_realign_skb':
include/linux/skbuff.h:3378:2: error: 'memcpy' source argument is the same as destination [-Werror=restrict]
  memcpy(skb->data, from, len);

It's unclear to me what the best solution is, maybe it ought to use a
different helper that adjusts the skb data in a safe way. Simply using
memmove() here seems like the easiest workaround.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 drivers/net/ethernet/qlogic/qlge/qlge_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

-- 
2.9.0

Comments

David Miller Feb. 3, 2018, 12:46 a.m. | #1
From: Arnd Bergmann <arnd@arndb.de>

Date: Fri,  2 Feb 2018 16:45:44 +0100

> gcc-8 points out that the skb_copy_to_linear_data() argument points to

> the skb itself, which makes it run into a problem with overlapping

> memcpy arguments:

> 

> In file included from include/linux/ip.h:20,

>                  from drivers/net/ethernet/qlogic/qlge/qlge_main.c:26:

> drivers/net/ethernet/qlogic/qlge/qlge_main.c: In function 'ql_realign_skb':

> include/linux/skbuff.h:3378:2: error: 'memcpy' source argument is the same as destination [-Werror=restrict]

>   memcpy(skb->data, from, len);

> 

> It's unclear to me what the best solution is, maybe it ought to use a

> different helper that adjusts the skb data in a safe way. Simply using

> memmove() here seems like the easiest workaround.

> 

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>


This looks fine, applied, thanks.

Patch

diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_main.c b/drivers/net/ethernet/qlogic/qlge/qlge_main.c
index 7b97a9969046..50038d946ced 100644
--- a/drivers/net/ethernet/qlogic/qlge/qlge_main.c
+++ b/drivers/net/ethernet/qlogic/qlge/qlge_main.c
@@ -1747,8 +1747,7 @@  static void ql_realign_skb(struct sk_buff *skb, int len)
 	 */
 	skb->data -= QLGE_SB_PAD - NET_IP_ALIGN;
 	skb->tail -= QLGE_SB_PAD - NET_IP_ALIGN;
-	skb_copy_to_linear_data(skb, temp_addr,
-		(unsigned int)len);
+	memmove(skb->data, temp_addr, len);
 }
 
 /*