sys/net/gnrc/netif: only register netif after init was successful
If we call `netif_register()` before we can be sure that the interface can be configured, a 'zombie' interface remains in the list, causing all kinds of trouble down the line. Only call `netif_register()` if `init()` was successful.
This commit is contained in:
parent
efd8afd3ab
commit
a82bc64a34
@ -74,7 +74,6 @@ int gnrc_netif_create(gnrc_netif_t *netif, char *stack, int stacksize,
|
|||||||
#endif
|
#endif
|
||||||
rmutex_init(&netif->mutex);
|
rmutex_init(&netif->mutex);
|
||||||
netif->ops = ops;
|
netif->ops = ops;
|
||||||
netif_register((netif_t*) netif);
|
|
||||||
assert(netif->dev == NULL);
|
assert(netif->dev == NULL);
|
||||||
netif->dev = netdev;
|
netif->dev = netdev;
|
||||||
res = thread_create(stack, stacksize, priority, THREAD_CREATE_STACKTEST,
|
res = thread_create(stack, stacksize, priority, THREAD_CREATE_STACKTEST,
|
||||||
@ -1610,14 +1609,9 @@ static void *_gnrc_netif_thread(void *args)
|
|||||||
res = dev->driver->init(dev);
|
res = dev->driver->init(dev);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
LOG_ERROR("gnrc_netif: netdev init failed: %d\n", res);
|
LOG_ERROR("gnrc_netif: netdev init failed: %d\n", res);
|
||||||
/* unregister this netif instance */
|
|
||||||
netif->ops = NULL;
|
|
||||||
netif->pid = KERNEL_PID_UNDEF;
|
|
||||||
netif->dev = NULL;
|
|
||||||
dev->event_callback = NULL;
|
|
||||||
dev->context = NULL;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
netif_register(&netif->netif);
|
||||||
_configure_netdev(dev);
|
_configure_netdev(dev);
|
||||||
netif->ops->init(netif);
|
netif->ops->init(netif);
|
||||||
#if DEVELHELP
|
#if DEVELHELP
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user