Skip to contentSkip to conversation

NET: Fix system hanging if NET device is not installed

PATCH Superseded Jim Lin 3 participants 3 messages May 17, 2013 – Jun 19, 2013 Networking

lore
Share & tools
lore

Jim Lin

author
#0 lore raw

PATCH 1/1 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.

---
 net/net.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
net/net.c +2 -1
index df94789..7663b9c 100644
@@ -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;
 }
Signature · 1 line
1.7.7
#1 lore raw

PATCH 1/1 NET: Fix system hanging if NET device is not installed

Quoted 7 lines · Jim Lin

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.

This fixes the crash I was seeing on the Cardhu board. Thanks.

#2 lore raw

PATCH 1/1 NET: Fix system hanging if NET device is not installed

In reply to Jim Lin
Quoted 10 lines · Jim Lin

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.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130619/2dd57dd2/attachment.pgp>