Commit 1f044931 authored by Daniel Drake's avatar Daniel Drake Committed by David S. Miller

Fix MAC address access in 3c507, ibmlana, pcnet32 and libertas

Commit f001fde5 changed
net_device.dev_addr from a 32-byte array to a pointer.

I found 4 ethernet drivers which rely on sizeof(dev_addr), which are now
only copying 4 bytes of the address information on 32bit systems.

Fix them to use ETH_ALEN.
Signed-off-by: default avatarDaniel Drake <dsd@laptop.org>
Reviewed-by: default avatarJiri Pirko <jpirko@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f74dac08
...@@ -56,6 +56,7 @@ static const char version[] = ...@@ -56,6 +56,7 @@ static const char version[] =
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/if_ether.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -734,8 +735,7 @@ static void init_82586_mem(struct net_device *dev) ...@@ -734,8 +735,7 @@ static void init_82586_mem(struct net_device *dev)
memcpy_toio(lp->base, init_words + 5, sizeof(init_words) - 10); memcpy_toio(lp->base, init_words + 5, sizeof(init_words) - 10);
/* Fill in the station address. */ /* Fill in the station address. */
memcpy_toio(lp->base+SA_OFFSET, dev->dev_addr, memcpy_toio(lp->base+SA_OFFSET, dev->dev_addr, ETH_ALEN);
sizeof(dev->dev_addr));
/* The Tx-block list is written as needed. We just set up the values. */ /* The Tx-block list is written as needed. We just set up the values. */
lp->tx_cmd_link = IDLELOOP + 4; lp->tx_cmd_link = IDLELOOP + 4;
......
...@@ -87,6 +87,7 @@ special acknowledgements to: ...@@ -87,6 +87,7 @@ special acknowledgements to:
#include <linux/module.h> #include <linux/module.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/if_ether.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/bitops.h> #include <linux/bitops.h>
...@@ -988,7 +989,7 @@ static int __devinit ibmlana_init_one(struct device *kdev) ...@@ -988,7 +989,7 @@ static int __devinit ibmlana_init_one(struct device *kdev)
/* copy out MAC address */ /* copy out MAC address */
for (z = 0; z < sizeof(dev->dev_addr); z++) for (z = 0; z < ETH_ALEN; z++)
dev->dev_addr[z] = inb(dev->base_addr + MACADDRPROM + z); dev->dev_addr[z] = inb(dev->base_addr + MACADDRPROM + z);
/* print config */ /* print config */
......
...@@ -45,6 +45,7 @@ static const char *const version = ...@@ -45,6 +45,7 @@ static const char *const version =
#include <linux/crc32.h> #include <linux/crc32.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/if_ether.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
...@@ -1765,7 +1766,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) ...@@ -1765,7 +1766,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
/* if the ethernet address is not valid, force to 00:00:00:00:00:00 */ /* if the ethernet address is not valid, force to 00:00:00:00:00:00 */
if (!is_valid_ether_addr(dev->perm_addr)) if (!is_valid_ether_addr(dev->perm_addr))
memset(dev->dev_addr, 0, sizeof(dev->dev_addr)); memset(dev->dev_addr, 0, ETH_ALEN);
if (pcnet32_debug & NETIF_MSG_PROBE) { if (pcnet32_debug & NETIF_MSG_PROBE) {
printk(" %pM", dev->dev_addr); printk(" %pM", dev->dev_addr);
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/if_ether.h>
#include <linux/if_arp.h> #include <linux/if_arp.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/kfifo.h> #include <linux/kfifo.h>
...@@ -351,8 +352,7 @@ int lbs_add_mesh(struct lbs_private *priv) ...@@ -351,8 +352,7 @@ int lbs_add_mesh(struct lbs_private *priv)
mesh_dev->netdev_ops = &mesh_netdev_ops; mesh_dev->netdev_ops = &mesh_netdev_ops;
mesh_dev->ethtool_ops = &lbs_ethtool_ops; mesh_dev->ethtool_ops = &lbs_ethtool_ops;
memcpy(mesh_dev->dev_addr, priv->dev->dev_addr, memcpy(mesh_dev->dev_addr, priv->dev->dev_addr, ETH_ALEN);
sizeof(priv->dev->dev_addr));
SET_NETDEV_DEV(priv->mesh_dev, priv->dev->dev.parent); SET_NETDEV_DEV(priv->mesh_dev, priv->dev->dev.parent);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment