commit fb85b1d1a760729b59fd6a866886ea1d5ccc1b34
parent d7dbbf66a0443845675d5246207815c9ffffac49
Author: Andrew Zaborowski <andrew.zaborowski@intel.com>
Date: Fri, 5 Oct 2018 03:53:14 +0200
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.
Diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/netdev.c b/src/netdev.c
@@ -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);