3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 14:49:24 +01:00

netdev: Check ifi_flags in netdev_connect/disconnect

Also, set the flags appropriately when removing the netdev object.  This
prevents callers from accidentally starting any actions that will simply
fail.
This commit is contained in:
Denis Kenzior 2021-05-28 22:39:05 -05:00
parent 11f42e2476
commit 2b0b5d4173

View File

@ -802,6 +802,8 @@ static void netdev_free(void *data)
l_debug("Freeing netdev %s[%d]", netdev->name, netdev->index);
netdev->ifi_flags &= ~IFF_UP;
if (netdev->events_ready)
WATCHLIST_NOTIFY(&netdev_watches, netdev_watch_func_t,
netdev, NETDEV_WATCH_EVENT_DEL);
@ -3293,6 +3295,9 @@ int netdev_connect(struct netdev *netdev, struct scan_bss *bss,
struct eapol_sm *sm = NULL;
bool is_rsn = hs->supplicant_ie != NULL;
if (!(netdev->ifi_flags & IFF_UP))
return -ENETDOWN;
if (netdev->type != NL80211_IFTYPE_STATION &&
netdev->type != NL80211_IFTYPE_P2P_CLIENT)
return -ENOTSUP;
@ -3367,6 +3372,9 @@ int netdev_disconnect(struct netdev *netdev,
struct l_genl_msg *disconnect;
bool send_disconnect = true;
if (!(netdev->ifi_flags & IFF_UP))
return -ENETDOWN;
if (netdev->type != NL80211_IFTYPE_STATION &&
netdev->type != NL80211_IFTYPE_P2P_CLIENT)
return -ENOTSUP;