summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Liu <r64343@freescale.com>2010-08-05 16:07:00 +0800
committerJason Liu <r64343@freescale.com>2010-08-05 16:12:07 +0800
commit87fee8558dfb5d5fcbb1f68674dc2922b9e5de76 (patch)
treeb1de6be189303a3b78a7f11f86633e4be01e0646
parent6d872e1a4c85f05764fdf86cbff074a36021702a (diff)
ENGR00125986 FEC:Fix kernel oops for mac address set up
There is no fec platform data for MX51 EVK board, so memcpy(fec_mac_default, pdata->mac, sizeof(fec_mac_default)); will cause memory issues and lead to the following oops: FEC Ethernet Driver Unable to handle kernel NULL pointer dereference at virtual address 00000004 pgd = 80004000 [00000004] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT Modules linked in: CPU: 0 Not tainted (2.6.31-00836-gb471a66 #233) PC is at memcpy+0x8c/0x330 This patch fix this issue which induced by commit 1f128b74b0dad4596ece46baf242562b093d2544 Signed-off-by:Jason Liu <r64343@freescale.com>
-rw-r--r--drivers/net/fec.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 38ee7ccff42c..75deb68ae1b4 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -1446,9 +1446,6 @@ fec_probe(struct platform_device *pdev)
fep = netdev_priv(ndev);
memset(fep, 0, sizeof(*fep));
- if (!is_valid_ether_addr(fec_mac_default))
- memcpy(fec_mac_default, pdata->mac, sizeof(fec_mac_default));
-
ndev->base_addr = (unsigned long)ioremap(r->start, resource_size(r));
fep->pdev = pdev;
@@ -1487,6 +1484,18 @@ fec_probe(struct platform_device *pdev)
fep->phy_interface = pdata->phy;
if (pdata->init && pdata->init())
goto failed_platform_init;
+
+ /*
+ * The priority for getting MAC address is:
+ * (1) kernel command line fec_mac = xx:xx:xx...
+ * (2) platform data mac field got from fuse etc
+ * (3) bootloader set the FEC mac register
+ */
+
+ if (!is_valid_ether_addr(fec_mac_default) &&
+ pdata->mac && is_valid_ether_addr(pdata->mac))
+ memcpy(fec_mac_default, pdata->mac,
+ sizeof(fec_mac_default));
} else
fep->phy_interface = PHY_INTERFACE_MODE_MII;