Add more sanity checks to the API handling, we shouldn't
be able to create a station without links, nor should we
be able to add a link to a station that wasn't created as
an MLD with links in the first place.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
if (!sta)
return -ENOENT;
+ if (!sta->sta.valid_links)
+ return -EINVAL;
+
if (sta->sta.valid_links & BIT(params->link_id))
return -EALREADY;
if (!(sta->sta.valid_links & BIT(params->link_id)))
return -EINVAL;
+ /* must not create a STA without links */
+ if (sta->sta.valid_links == BIT(params->link_id))
+ return -EINVAL;
+
ieee80211_sta_remove_link(sta, params->link_id);
return 0;