[U-Boot] [PATCH 1/1 RESEND] NET: Fix system hanging if NET device is not installed

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 --- net/net.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/net/net.c b/net/net.c index df94789..7663b9c 100644 --- 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; }

On 06/05/2013 01:07 AM, Jim Lin wrote:
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.
Oh, you didn't send this patch to anyone, just the mailing list. I added the net maintainer to Cc so he'll see this patch.
BTW, this is a critical bugfix, to avoid hangs without any USB Ethernet device attached.
participants (2)
-
Jim Lin
-
Stephen Warren