A small fix to davinci_emac driver
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): 028901c9f54b$4579eae0$d06dc0a0$@com
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hello all,
I have attached a small fix for the following problem:
When davinci_emac interface is down, changing MAC address results in kernel oops, due to NULL pointer dereference.
I apologize for not inlining the patch into the message (since GMail is the only web client I can use, and it does not allow me to inline it correctly).
Remarks are welcomed.
Thanks in advance.
Quoted 12 lines · Sekhar
Pablo,
Chaithrika's mails to gmail.com are bouncing, so I am replying on her behalf.
"
You are right there is indeed an issue. We looked at other drivers and found that this is solved by checking fornetif_runningto be true before going ahead and setting the mac address. Have a look at how this is done intg3.cdriver
Quoted 31 lines
Can you please go ahead and submit a fix for this to netdev mailing list and CC linux-davinci ML?
Thanks,
SekharQuoted 21 lines
-----Original Message-----
From: Pablo Bitton [mailto:[email protected]]
Sent: Wednesday, June 24, 2009 7:13 PM
To: Subrahmanya, Chaithrika
Subject: A small fix todavinci_emacdriverHello,
In
drivers/net/davinci_emac.cfile, atemac_dev_setmac_addr()function, rxch is 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 torxch->mac_addr, which causes a kernel oops.In order to fix this situation, the attached patch is applied (I've couldn't inline it correctly into GMail).
Remarks are welcomed.Thanks in advance.
From ae9480af26eba3302614ea3d92077a80341cd190 Mon Sep 17 00:00:00 2001
From: Pablo Bitton <[email protected]>
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.
--- drivers/net/davinci_emac.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
drivers/net/davinci_emac.c +7 -2
@@ -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",
Signature · 1 line
1.5.4.3
Quoted 5 lines · Pablo Bitton
Hello all,
I have attached a small fix for the following problem:
Whendavinci_emacinterface is down, changing MAC address results in kernel oops, due to NULL pointer dereference.
This should go linux-net after a signoff from Sekhar or Chaithrika.
Quoted 3 lines
I apologize for not inlining the patch into the message (since GMail is the only web client I can use, and it does not allow me to inline it correctly).
You can send via Gmail using git-send-email directly. Read this:
http://git.or.cz/gitwiki/GitTips#Mail
Kevin
Quoted 92 lines
Remarks are welcomed.
Thanks in advance.
Quoted 12 lines · Sekhar
Pablo,
Chaithrika's mails to gmail.com are bouncing, so I am replying on her behalf.
"
You are right there is indeed an issue. We looked at other drivers and found that this is solved by checking fornetif_runningto be true before going ahead and setting the mac address. Have a look at how this is done intg3.cdriverQuoted 31 lines
Can you please go ahead and submit a fix for this to netdev mailing list and CC linux-davinci ML?
Thanks,
SekharQuoted 21 lines
-----Original Message-----
From: Pablo Bitton [mailto:[email protected]]
Sent: Wednesday, June 24, 2009 7:13 PM
To: Subrahmanya, Chaithrika
Subject: A small fix todavinci_emacdriverHello,
In
drivers/net/davinci_emac.cfile, atemac_dev_setmac_addr()function, rxch is 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 torxch->mac_addr, which causes a kernel oops.In order to fix this situation, the attached patch is applied (I've couldn't inline it correctly into GMail).
Remarks are welcomed.Thanks in advance.
From
ae9480af26eba3302614ea3d92077a80341cd190Mon Sep 17 00:00:00 2001
From: Pablo Bitton <[email protected]>
Date: Tue, 23 Jun 2009 15:45:43 +0300
Subject: [PATCH]davinci_emac: fix kernel oops when changing MAC address while interface is downrxch == 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 torxch->mac_addr, which causes a kernel oops.Signed-off-by Pablo Bitton <[email protected]>--- drivers/net/davinci_emac.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)drivers/net/davinci_emac.c +7
-2@@ -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",Signature · 6 lines
1.5.4.3 _______________________________________________ Davinci-linux-open-source mailing list [email protected] http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source