aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Bitton <pablo.bitton@gmail.com>2009-07-07 22:11:10 -0400
committerDavid S. Miller <davem@davemloft.net>2009-07-08 13:46:44 -0400
commit64c8165b44a91c09b19afb4110610ed242286639 (patch)
treeb7e4754f6280248b5444d4ff908c29684307ca11
parent19e588e7d156cc4415585edd8c27c3075f62eaf8 (diff)
davinci_emac: fix kernel oops when changing MAC address while interface is down
Check that network interface is running before changing its MAC address. Otherwise, rxch is accessed when it's NULL - causing a kernel oops. Moreover, check that the new MAC address is valid. Signed-off-by: Pablo Bitton <pablo.bitton@gmail.com> Signed-off-by: Chaithrika U S <chaithrika@ti.com> Tested-by: Chaithrika U S <chaithrika@ti.com> [tested on DM6467 EVM] Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/davinci_emac.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 2df8fb0af701..12fd446f9895 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -1820,11 +1820,19 @@ static int emac_dev_setmac_addr(struct net_device *ndev, void *addr)
1820 struct device *emac_dev = &priv->ndev->dev; 1820 struct device *emac_dev = &priv->ndev->dev;
1821 struct sockaddr *sa = addr; 1821 struct sockaddr *sa = addr;
1822 1822
1823 if (!is_valid_ether_addr(sa->sa_data))
1824 return -EINVAL;
1825
1823 /* Store mac addr in priv and rx channel and set it in EMAC hw */ 1826 /* Store mac addr in priv and rx channel and set it in EMAC hw */
1824 memcpy(priv->mac_addr, sa->sa_data, ndev->addr_len); 1827 memcpy(priv->mac_addr, sa->sa_data, ndev->addr_len);
1825 memcpy(rxch->mac_addr, sa->sa_data, ndev->addr_len);
1826 memcpy(ndev->dev_addr, sa->sa_data, ndev->addr_len); 1828 memcpy(ndev->dev_addr, sa->sa_data, ndev->addr_len);
1827 emac_setmac(priv, EMAC_DEF_RX_CH, rxch->mac_addr); 1829
1830 /* If the interface is down - rxch is NULL. */
1831 /* MAC address is configured only after the interface is enabled. */
1832 if (netif_running(ndev)) {
1833 memcpy(rxch->mac_addr, sa->sa_data, ndev->addr_len);
1834 emac_setmac(priv, EMAC_DEF_RX_CH, rxch->mac_addr);
1835 }
1828 1836
1829 if (netif_msg_drv(priv)) 1837 if (netif_msg_drv(priv))
1830 dev_notice(emac_dev, "DaVinci EMAC: emac_dev_setmac_addr %pM\n", 1838 dev_notice(emac_dev, "DaVinci EMAC: emac_dev_setmac_addr %pM\n",