mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drivers/net/usb: Correct code taking the size of a pointer
@ 2009-12-13 15:47 Julia Lawall
  2009-12-14  3:58 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2009-12-13 15:47 UTC (permalink / raw)
  To: Petko Manolov, Greg Kroah-Hartman, linux-usb, netdev,
	linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

sizeof(dev->dev_addr) is the size of a pointer.  A few lines above, the
size of this field is obtained using netdev->addr_len for a call to memcpy,
so do the same here.

A simplified version of the semantic patch that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression *x;
expression f;
type T;
@@

*f(...,(T)x,...)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/net/usb/rtl8150.c           |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
index b091e20..f14d225 100644
--- a/drivers/net/usb/rtl8150.c
+++ b/drivers/net/usb/rtl8150.c
@@ -324,7 +324,7 @@ static int rtl8150_set_mac_address(struct net_device *netdev, void *p)
 		dbg("%02X:", netdev->dev_addr[i]);
 	dbg("%02X\n", netdev->dev_addr[i]);
 	/* Set the IDR registers. */
-	set_registers(dev, IDR, sizeof(netdev->dev_addr), netdev->dev_addr);
+	set_registers(dev, IDR, netdev->addr_len, netdev->dev_addr);
 #ifdef EEPROM_WRITE
 	{
 	u8 cr;

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

* Re: [PATCH] drivers/net/usb: Correct code taking the size of a pointer
  2009-12-13 15:47 [PATCH] drivers/net/usb: Correct code taking the size of a pointer Julia Lawall
@ 2009-12-14  3:58 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2009-12-14  3:58 UTC (permalink / raw)
  To: julia; +Cc: petkan, gregkh, linux-usb, netdev, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>
Date: Sun, 13 Dec 2009 16:47:04 +0100 (CET)

> From: Julia Lawall <julia@diku.dk>
> 
> sizeof(dev->dev_addr) is the size of a pointer.  A few lines above, the
> size of this field is obtained using netdev->addr_len for a call to memcpy,
> so do the same here.
> 
> A simplified version of the semantic patch that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
 ...
> Signed-off-by: Julia Lawall <julia@diku.dk>

Applied.

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

end of thread, other threads:[~2009-12-14  3:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-13 15:47 [PATCH] drivers/net/usb: Correct code taking the size of a pointer Julia Lawall
2009-12-14  3:58 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®