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

netdev: Track the id of the SET_STATION netlink command

This way we make sure it gets cancelled any sort of connect abort of
netdev removal and don't leak the message on error.
This commit is contained in:
Andrew Zaborowski 2017-10-21 01:27:21 +02:00 committed by Denis Kenzior
parent a03839f8ef
commit 4dba9e37dd

View File

@ -78,6 +78,7 @@ struct netdev {
uint32_t pairwise_set_key_cmd_id; uint32_t pairwise_set_key_cmd_id;
uint32_t group_new_key_cmd_id; uint32_t group_new_key_cmd_id;
uint32_t group_management_new_key_cmd_id; uint32_t group_management_new_key_cmd_id;
uint32_t set_station_cmd_id;
uint32_t connect_cmd_id; uint32_t connect_cmd_id;
uint32_t disconnect_cmd_id; uint32_t disconnect_cmd_id;
enum netdev_result result; enum netdev_result result;
@ -476,6 +477,11 @@ static void netdev_connect_free(struct netdev *netdev)
netdev->group_management_new_key_cmd_id = 0; netdev->group_management_new_key_cmd_id = 0;
} }
if (netdev->set_station_cmd_id) {
l_genl_family_cancel(nl80211, netdev->set_station_cmd_id);
netdev->set_station_cmd_id = 0;
}
if (netdev->connect_cmd_id) { if (netdev->connect_cmd_id) {
l_genl_family_cancel(nl80211, netdev->connect_cmd_id); l_genl_family_cancel(nl80211, netdev->connect_cmd_id);
netdev->connect_cmd_id = 0; netdev->connect_cmd_id = 0;
@ -893,6 +899,9 @@ static void netdev_setting_keys_failed(struct netdev *netdev,
netdev->group_management_new_key_cmd_id); netdev->group_management_new_key_cmd_id);
netdev->group_management_new_key_cmd_id = 0; netdev->group_management_new_key_cmd_id = 0;
l_genl_family_cancel(nl80211, netdev->set_station_cmd_id);
netdev->set_station_cmd_id = 0;
netdev->result = NETDEV_RESULT_KEY_SETTING_FAILED; netdev->result = NETDEV_RESULT_KEY_SETTING_FAILED;
msg = netdev_build_cmd_disconnect(netdev, msg = netdev_build_cmd_disconnect(netdev,
MMPDU_REASON_CODE_UNSPECIFIED); MMPDU_REASON_CODE_UNSPECIFIED);
@ -906,6 +915,8 @@ static void netdev_set_station_cb(struct l_genl_msg *msg, void *user_data)
struct netdev *netdev = user_data; struct netdev *netdev = user_data;
int err; int err;
netdev->set_station_cmd_id = 0;
if (!netdev->connected) if (!netdev->connected)
return; return;
@ -1127,9 +1138,13 @@ static void netdev_set_pairwise_key_cb(struct l_genl_msg *msg, void *data)
msg = netdev_build_cmd_set_station(netdev); msg = netdev_build_cmd_set_station(netdev);
l_genl_family_send(nl80211, msg, netdev_set_station_cb, netdev, NULL); netdev->set_station_cmd_id =
return; l_genl_family_send(nl80211, msg, netdev_set_station_cb,
netdev, NULL);
if (netdev->set_station_cmd_id > 0)
return;
l_genl_msg_unref(msg);
error: error:
netdev_setting_keys_failed(netdev, MMPDU_REASON_CODE_UNSPECIFIED); netdev_setting_keys_failed(netdev, MMPDU_REASON_CODE_UNSPECIFIED);
} }