mirror of
https://github.com/torvalds/linux.git
synced 2026-06-03 12:03:54 +02:00
wifi: nl80211: make nl80211_check_scan_flags() type safe
The cast from void * here coupled with the boolean argument on what to cast to is confusing and really not needed, just split the code and make a type-safe interface. It seems to even reduce the code size slightly, at least on x86-64. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20250609213231.bdb3c96570b0.Ia153e6ce06dc9a636ff5bcc1d52468a1afd06e13@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
f0df91b6a7
commit
a1d9979c36
|
|
@ -9811,34 +9811,12 @@ static bool nl80211_check_scan_feat(struct wiphy *wiphy, u32 flags, u32 flag,
|
|||
|
||||
static int
|
||||
nl80211_check_scan_flags(struct wiphy *wiphy, struct wireless_dev *wdev,
|
||||
void *request, struct nlattr **attrs,
|
||||
bool is_sched_scan)
|
||||
struct nlattr **attrs, u8 *mac_addr, u8 *mac_addr_mask,
|
||||
u32 *flags, enum nl80211_feature_flags randomness_flag)
|
||||
{
|
||||
u8 *mac_addr, *mac_addr_mask;
|
||||
u32 *flags;
|
||||
enum nl80211_feature_flags randomness_flag;
|
||||
|
||||
if (!attrs[NL80211_ATTR_SCAN_FLAGS])
|
||||
return 0;
|
||||
|
||||
if (is_sched_scan) {
|
||||
struct cfg80211_sched_scan_request *req = request;
|
||||
|
||||
randomness_flag = wdev ?
|
||||
NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR :
|
||||
NL80211_FEATURE_ND_RANDOM_MAC_ADDR;
|
||||
flags = &req->flags;
|
||||
mac_addr = req->mac_addr;
|
||||
mac_addr_mask = req->mac_addr_mask;
|
||||
} else {
|
||||
struct cfg80211_scan_request_int *req = request;
|
||||
|
||||
randomness_flag = NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR;
|
||||
flags = &req->req.flags;
|
||||
mac_addr = req->req.mac_addr;
|
||||
mac_addr_mask = req->req.mac_addr_mask;
|
||||
}
|
||||
|
||||
*flags = nla_get_u32(attrs[NL80211_ATTR_SCAN_FLAGS]);
|
||||
|
||||
if (((*flags & NL80211_SCAN_FLAG_LOW_PRIORITY) &&
|
||||
|
|
@ -9887,6 +9865,30 @@ nl80211_check_scan_flags(struct wiphy *wiphy, struct wireless_dev *wdev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
nl80211_check_scan_flags_sched(struct wiphy *wiphy, struct wireless_dev *wdev,
|
||||
struct nlattr **attrs,
|
||||
struct cfg80211_sched_scan_request *req)
|
||||
{
|
||||
return nl80211_check_scan_flags(wiphy, wdev, attrs,
|
||||
req->mac_addr, req->mac_addr_mask,
|
||||
&req->flags,
|
||||
wdev ? NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR :
|
||||
NL80211_FEATURE_ND_RANDOM_MAC_ADDR);
|
||||
}
|
||||
|
||||
static int
|
||||
nl80211_check_scan_flags_reg(struct wiphy *wiphy, struct wireless_dev *wdev,
|
||||
struct nlattr **attrs,
|
||||
struct cfg80211_scan_request_int *req)
|
||||
{
|
||||
return nl80211_check_scan_flags(wiphy, wdev, attrs,
|
||||
req->req.mac_addr,
|
||||
req->req.mac_addr_mask,
|
||||
&req->req.flags,
|
||||
NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR);
|
||||
}
|
||||
|
||||
static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
|
||||
{
|
||||
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
||||
|
|
@ -10083,8 +10085,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
|
|||
nla_get_flag(info->attrs[NL80211_ATTR_MEASUREMENT_DURATION_MANDATORY]);
|
||||
}
|
||||
|
||||
err = nl80211_check_scan_flags(wiphy, wdev, request, info->attrs,
|
||||
false);
|
||||
err = nl80211_check_scan_flags_reg(wiphy, wdev, info->attrs, request);
|
||||
if (err)
|
||||
goto out_free;
|
||||
|
||||
|
|
@ -10537,7 +10538,7 @@ nl80211_parse_sched_scan(struct wiphy *wiphy, struct wireless_dev *wdev,
|
|||
request->ie_len);
|
||||
}
|
||||
|
||||
err = nl80211_check_scan_flags(wiphy, wdev, request, attrs, true);
|
||||
err = nl80211_check_scan_flags_sched(wiphy, wdev, attrs, request);
|
||||
if (err)
|
||||
goto out_free;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user