drivers/net/usb: Correct code taking the size of a pointer
authorJulia Lawall <julia@diku.dk>
Sun, 13 Dec 2009 05:47:04 +0000 (05:47 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 14 Dec 2009 03:56:35 +0000 (19:56 -0800)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/rtl8150.c

index b091e20ca1679d82544751a5aa39683b69d244ac..f14d225404da59c5b5ce84b6e3849663e799aca1 100644 (file)
@@ -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;