From ae9480af26eba3302614ea3d92077a80341cd190 Mon Sep 17 00:00:00 2001 From: Pablo Bitton Date: Tue, 23 Jun 2009 15:45:43 +0300 Subject: [PATCH] davinci_emac: fix kernel oops when changing MAC address while interface is down rxch == NULL when DaVinci EMAC is down (using "ifconfig eth0 down"). So when MAC address is changed using "ifconfig eth0 hw ether 00:11:22:33:44:55", emac_dev_setmac_addr() performs an illegal access to rxch->mac_addr, which causes a kernel oops. Signed-off-by: Pablo Bitton --- drivers/net/davinci_emac.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c index cf689a0..cd114d9 100644 --- a/drivers/net/davinci_emac.c +++ b/drivers/net/davinci_emac.c @@ -1823,9 +1823,14 @@ static int emac_dev_setmac_addr(struct net_device *ndev, void *addr) /* Store mac addr in priv and rx channel and set it in EMAC hw */ memcpy(priv->mac_addr, sa->sa_data, ndev->addr_len); - memcpy(rxch->mac_addr, sa->sa_data, ndev->addr_len); memcpy(ndev->dev_addr, sa->sa_data, ndev->addr_len); - emac_setmac(priv, EMAC_DEF_RX_CH, rxch->mac_addr); + + /* If the interface is down - rxch is NULL. */ + /* MAC address is configured only after the interface is enabled. */ + if (netif_running(ndev)) { + memcpy(rxch->mac_addr, sa->sa_data, ndev->addr_len); + emac_setmac(priv, EMAC_DEF_RX_CH, rxch->mac_addr); + } if (netif_msg_drv(priv)) dev_notice(emac_dev, "DaVinci EMAC: emac_dev_setmac_addr %s\n", -- 1.5.4.3