greth: greth_set_mac_add would corrupt the MAC address.
authorKristoffer Glembo <kristoffer@gaisler.com>
Tue, 5 Jul 2011 04:39:10 +0000 (21:39 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 5 Jul 2011 04:39:10 +0000 (21:39 -0700)
The MAC address was set using the signed char sockaddr->sa_addr
field and thus the address could be corrupted through sign extension.

Signed-off-by: Kristoffer Glembo <kristoffer@gaisler.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/greth.c

index f181304a7ab6464b809b0bf7fc7a436a3721f006..672f096fe0905d8a59bf6efb495922e51b031c48 100644 (file)
@@ -1015,11 +1015,10 @@ static int greth_set_mac_add(struct net_device *dev, void *p)
                return -EINVAL;
 
        memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+       GRETH_REGSAVE(regs->esa_msb, dev->dev_addr[0] << 8 | dev->dev_addr[1]);
+       GRETH_REGSAVE(regs->esa_lsb, dev->dev_addr[2] << 24 | dev->dev_addr[3] << 16 |
+                     dev->dev_addr[4] << 8 | dev->dev_addr[5]);
 
-       GRETH_REGSAVE(regs->esa_msb, addr->sa_data[0] << 8 | addr->sa_data[1]);
-       GRETH_REGSAVE(regs->esa_lsb,
-                     addr->sa_data[2] << 24 | addr->
-                     sa_data[3] << 16 | addr->sa_data[4] << 8 | addr->sa_data[5]);
        return 0;
 }