1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

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:
Benjamin Valentin 2021-02-01 19:13:41 +01:00
parent efd8afd3ab
commit a82bc64a34

View File

@ -74,7 +74,6 @@ int gnrc_netif_create(gnrc_netif_t *netif, char *stack, int stacksize,
#endif
rmutex_init(&netif->mutex);
netif->ops = ops;
netif_register((netif_t*) netif);
assert(netif->dev == NULL);
netif->dev = netdev;
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);
if (res < 0) {
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;
}
netif_register(&netif->netif);
_configure_netdev(dev);
netif->ops->init(netif);
#if DEVELHELP