]> git.sur5r.net Git - u-boot/blobdiff - net/net.c
net: Protect net_state from reentrant net_loop()
[u-boot] / net / net.c
index a4932f46d905f51d0466983b2032a35b134e4e73..b4563a4cab1fbfbccf595ee40a5e865514d79884 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -393,6 +393,7 @@ void net_init(void)
 int net_loop(enum proto_t protocol)
 {
        int ret = -EINVAL;
+       enum net_loop_state prev_net_state = net_state;
 
        net_restarted = 0;
        net_dev_exists = 0;
@@ -430,6 +431,7 @@ restart:
        case 1:
                /* network not configured */
                eth_halt();
+               net_set_state(prev_net_state);
                return -ENODEV;
 
        case 2:
@@ -655,6 +657,7 @@ done:
        net_set_udp_handler(NULL);
        net_set_icmp_handler(NULL);
 #endif
+       net_set_state(prev_net_state);
        return ret;
 }