summaryrefslogtreecommitdiffstats
path: root/drivers/net/greth.c
diff options
context:
space:
mode:
authorKristoffer Glembo <kristoffer@gaisler.com>2011-07-04 21:39:10 -0700
committerDavid S. Miller <davem@davemloft.net>2011-07-04 21:39:10 -0700
commit9b9cfe7cf663c16c0d93349cc0094bb28ae7135a (patch)
tree24b51f8b2e8c3f7324dbde57e2cc6c0dd28ebe66 /drivers/net/greth.c
parentc349a528cd47e2272ded0ea358363855e86180da (diff)
downloadop-kernel-dev-9b9cfe7cf663c16c0d93349cc0094bb28ae7135a.zip
op-kernel-dev-9b9cfe7cf663c16c0d93349cc0094bb28ae7135a.tar.gz
greth: greth_set_mac_add would corrupt the MAC address.
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>
Diffstat (limited to 'drivers/net/greth.c')
-rw-r--r--drivers/net/greth.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/net/greth.c b/drivers/net/greth.c
index f181304..672f096 100644
--- a/drivers/net/greth.c
+++ b/drivers/net/greth.c
@@ -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;
}
OpenPOWER on IntegriCloud