diff --git a/src/wiphy.c b/src/wiphy.c index b098216d..d3065bef 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -1142,14 +1142,13 @@ struct device *device_create(struct wiphy *wiphy, struct netdev *netdev) return device; } -void device_remove(struct device *device) +static void device_free(void *user) { + struct device *device = user; struct l_dbus *dbus; l_debug(""); - l_queue_remove(device_list, device); - if (device->scan_pending) dbus_pending_reply(&device->scan_pending, dbus_error_aborted(device->scan_pending)); @@ -1178,6 +1177,14 @@ void device_remove(struct device *device) l_free(device); } +void device_remove(struct device *device) +{ + if (!l_queue_remove(device_list, device)) + return; + + device_free(device); +} + struct wiphy *wiphy_find(int wiphy_id) { return l_queue_find(wiphy_list, wiphy_match, L_UINT_TO_PTR(wiphy_id)); @@ -1676,7 +1683,7 @@ bool wiphy_exit(void) l_queue_destroy(wiphy_list, wiphy_free); wiphy_list = NULL; - l_queue_destroy(device_list, (l_queue_destroy_func_t) device_remove); + l_queue_destroy(device_list, device_free); device_list = NULL; nl80211 = NULL;