NET: Fix system hanging if NET device is not installed
authorJim Lin <jilin@nvidia.com>
Fri, 17 May 2013 09:41:03 +0000 (17:41 +0800)
committerTom Rini <trini@ti.com>
Wed, 19 Jun 2013 12:32:44 +0000 (08:32 -0400)
If we try to boot from NET device, NetInitLoop in net.c will be invoked.
If NET device is not installed, eth_get_dev() function will return
eth_current value, which is NULL.
When NetInitLoop is called, "eth_get_dev->enetaddr" will access
restricted memory area and therefore cause hanging.
This issue is found on Tegra30 Cardhu platform after adding
CONFIG_CMD_NET and CONFIG_CMD_DHCP in config header file.

Signed-off-by: Jim Lin <jilin@nvidia.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
net/net.c

index df94789de95f603000d91b2e14d0fec16b544e31..7663b9cd6c92541b657fb3eebcbd72ba98b9a6df 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -271,7 +271,8 @@ static void NetInitLoop(void)
 #endif
                env_changed_id = env_id;
        }
-       memcpy(NetOurEther, eth_get_dev()->enetaddr, 6);
+       if (eth_get_dev())
+               memcpy(NetOurEther, eth_get_dev()->enetaddr, 6);
 
        return;
 }