3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-21 03:32:42 +01:00

netdev: Check that netdev->device is not NULL

Check that netdev->device is not NULL before doing device_remove()
(which would crash) and emitting NETDEV_WATCH_EVENT_DEL.  It may be
NULL if the initial RTM_SETLINK has failed to bring device UP.
This commit is contained in:
Andrew Zaborowski 2018-10-05 03:53:14 +02:00 committed by Denis Kenzior
parent d7dbbf66a0
commit fb85b1d1a7

View File

@ -612,9 +612,11 @@ static void netdev_free(void *data)
netdev->set_powered_cmd_id = 0;
}
WATCHLIST_NOTIFY(&netdev_watches, netdev_watch_func_t,
netdev, NETDEV_WATCH_EVENT_DEL);
device_remove(netdev->device);
if (netdev->device) {
WATCHLIST_NOTIFY(&netdev_watches, netdev_watch_func_t,
netdev, NETDEV_WATCH_EVENT_DEL);
device_remove(netdev->device);
}
watchlist_destroy(&netdev->frame_watches);
watchlist_destroy(&netdev->station_watches);