Commit bfe2c7b1 authored by Johannes Berg's avatar Johannes Berg

nl80211: use nla_parse_nested() instead of nla_parse()

It's just an inline doing the same thing, but the code
is nicer with it.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 1794899e
...@@ -2319,10 +2319,9 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) ...@@ -2319,10 +2319,9 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
nla_for_each_nested(nl_txq_params, nla_for_each_nested(nl_txq_params,
info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS], info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS],
rem_txq_params) { rem_txq_params) {
result = nla_parse(tb, NL80211_TXQ_ATTR_MAX, result = nla_parse_nested(tb, NL80211_TXQ_ATTR_MAX,
nla_data(nl_txq_params), nl_txq_params,
nla_len(nl_txq_params), txq_params_policy);
txq_params_policy);
if (result) if (result)
return result; return result;
result = parse_txq_params(tb, &txq_params); result = parse_txq_params(tb, &txq_params);
...@@ -3572,8 +3571,8 @@ static int nl80211_parse_tx_bitrate_mask(struct genl_info *info, ...@@ -3572,8 +3571,8 @@ static int nl80211_parse_tx_bitrate_mask(struct genl_info *info,
sband = rdev->wiphy.bands[band]; sband = rdev->wiphy.bands[band];
if (sband == NULL) if (sband == NULL)
return -EINVAL; return -EINVAL;
err = nla_parse(tb, NL80211_TXRATE_MAX, nla_data(tx_rates), err = nla_parse_nested(tb, NL80211_TXRATE_MAX, tx_rates,
nla_len(tx_rates), nl80211_txattr_policy); nl80211_txattr_policy);
if (err) if (err)
return err; return err;
if (tb[NL80211_TXRATE_LEGACY]) { if (tb[NL80211_TXRATE_LEGACY]) {
...@@ -6329,9 +6328,8 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info) ...@@ -6329,9 +6328,8 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES], nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
rem_reg_rules) { rem_reg_rules) {
r = nla_parse(tb, NL80211_REG_RULE_ATTR_MAX, r = nla_parse_nested(tb, NL80211_REG_RULE_ATTR_MAX,
nla_data(nl_reg_rule), nla_len(nl_reg_rule), nl_reg_rule, reg_rule_policy);
reg_rule_policy);
if (r) if (r)
goto bad_reg; goto bad_reg;
r = parse_reg_rule(tb, &rd->reg_rules[rule_idx]); r = parse_reg_rule(tb, &rd->reg_rules[rule_idx]);
...@@ -6398,8 +6396,8 @@ static int parse_bss_select(struct nlattr *nla, struct wiphy *wiphy, ...@@ -6398,8 +6396,8 @@ static int parse_bss_select(struct nlattr *nla, struct wiphy *wiphy,
if (!nla_ok(nest, nla_len(nest))) if (!nla_ok(nest, nla_len(nest)))
return -EINVAL; return -EINVAL;
err = nla_parse(attr, NL80211_BSS_SELECT_ATTR_MAX, nla_data(nest), err = nla_parse_nested(attr, NL80211_BSS_SELECT_ATTR_MAX, nest,
nla_len(nest), nl80211_bss_select_policy); nl80211_bss_select_policy);
if (err) if (err)
return err; return err;
...@@ -6789,9 +6787,8 @@ nl80211_parse_sched_scan_plans(struct wiphy *wiphy, int n_plans, ...@@ -6789,9 +6787,8 @@ nl80211_parse_sched_scan_plans(struct wiphy *wiphy, int n_plans,
if (WARN_ON(i >= n_plans)) if (WARN_ON(i >= n_plans))
return -EINVAL; return -EINVAL;
err = nla_parse(plan, NL80211_SCHED_SCAN_PLAN_MAX, err = nla_parse_nested(plan, NL80211_SCHED_SCAN_PLAN_MAX,
nla_data(attr), nla_len(attr), attr, nl80211_plan_policy);
nl80211_plan_policy);
if (err) if (err)
return err; return err;
...@@ -6880,9 +6877,9 @@ nl80211_parse_sched_scan(struct wiphy *wiphy, struct wireless_dev *wdev, ...@@ -6880,9 +6877,9 @@ nl80211_parse_sched_scan(struct wiphy *wiphy, struct wireless_dev *wdev,
tmp) { tmp) {
struct nlattr *rssi; struct nlattr *rssi;
err = nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX, err = nla_parse_nested(tb,
nla_data(attr), nla_len(attr), NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
nl80211_match_policy); attr, nl80211_match_policy);
if (err) if (err)
return ERR_PTR(err); return ERR_PTR(err);
/* add other standalone attributes here */ /* add other standalone attributes here */
...@@ -7053,9 +7050,9 @@ nl80211_parse_sched_scan(struct wiphy *wiphy, struct wireless_dev *wdev, ...@@ -7053,9 +7050,9 @@ nl80211_parse_sched_scan(struct wiphy *wiphy, struct wireless_dev *wdev,
tmp) { tmp) {
struct nlattr *ssid, *rssi; struct nlattr *ssid, *rssi;
err = nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX, err = nla_parse_nested(tb,
nla_data(attr), nla_len(attr), NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
nl80211_match_policy); attr, nl80211_match_policy);
if (err) if (err)
goto out_free; goto out_free;
ssid = tb[NL80211_SCHED_SCAN_MATCH_ATTR_SSID]; ssid = tb[NL80211_SCHED_SCAN_MATCH_ATTR_SSID];
...@@ -9755,9 +9752,8 @@ static int nl80211_parse_wowlan_tcp(struct cfg80211_registered_device *rdev, ...@@ -9755,9 +9752,8 @@ static int nl80211_parse_wowlan_tcp(struct cfg80211_registered_device *rdev,
if (!rdev->wiphy.wowlan->tcp) if (!rdev->wiphy.wowlan->tcp)
return -EINVAL; return -EINVAL;
err = nla_parse(tb, MAX_NL80211_WOWLAN_TCP, err = nla_parse_nested(tb, MAX_NL80211_WOWLAN_TCP, attr,
nla_data(attr), nla_len(attr), nl80211_wowlan_tcp_policy);
nl80211_wowlan_tcp_policy);
if (err) if (err)
return err; return err;
...@@ -9902,9 +9898,7 @@ static int nl80211_parse_wowlan_nd(struct cfg80211_registered_device *rdev, ...@@ -9902,9 +9898,7 @@ static int nl80211_parse_wowlan_nd(struct cfg80211_registered_device *rdev,
goto out; goto out;
} }
err = nla_parse(tb, NL80211_ATTR_MAX, err = nla_parse_nested(tb, NL80211_ATTR_MAX, attr, nl80211_policy);
nla_data(attr), nla_len(attr),
nl80211_policy);
if (err) if (err)
goto out; goto out;
...@@ -9938,10 +9932,9 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) ...@@ -9938,10 +9932,9 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
goto set_wakeup; goto set_wakeup;
} }
err = nla_parse(tb, MAX_NL80211_WOWLAN_TRIG, err = nla_parse_nested(tb, MAX_NL80211_WOWLAN_TRIG,
nla_data(info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS]), info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS],
nla_len(info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS]), nl80211_wowlan_policy);
nl80211_wowlan_policy);
if (err) if (err)
return err; return err;
...@@ -10023,8 +10016,8 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) ...@@ -10023,8 +10016,8 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
rem) { rem) {
u8 *mask_pat; u8 *mask_pat;
nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat), nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat,
nla_len(pat), NULL); NULL);
err = -EINVAL; err = -EINVAL;
if (!pat_tb[NL80211_PKTPAT_MASK] || if (!pat_tb[NL80211_PKTPAT_MASK] ||
!pat_tb[NL80211_PKTPAT_PATTERN]) !pat_tb[NL80211_PKTPAT_PATTERN])
...@@ -10234,8 +10227,8 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev, ...@@ -10234,8 +10227,8 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev,
int rem, pat_len, mask_len, pkt_offset, n_patterns = 0; int rem, pat_len, mask_len, pkt_offset, n_patterns = 0;
struct nlattr *pat_tb[NUM_NL80211_PKTPAT]; struct nlattr *pat_tb[NUM_NL80211_PKTPAT];
err = nla_parse(tb, NL80211_ATTR_COALESCE_RULE_MAX, nla_data(rule), err = nla_parse_nested(tb, NL80211_ATTR_COALESCE_RULE_MAX, rule,
nla_len(rule), nl80211_coalesce_policy); nl80211_coalesce_policy);
if (err) if (err)
return err; return err;
...@@ -10273,8 +10266,7 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev, ...@@ -10273,8 +10266,7 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev,
rem) { rem) {
u8 *mask_pat; u8 *mask_pat;
nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat), nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat, NULL);
nla_len(pat), NULL);
if (!pat_tb[NL80211_PKTPAT_MASK] || if (!pat_tb[NL80211_PKTPAT_MASK] ||
!pat_tb[NL80211_PKTPAT_PATTERN]) !pat_tb[NL80211_PKTPAT_PATTERN])
return -EINVAL; return -EINVAL;
...@@ -10393,10 +10385,9 @@ static int nl80211_set_rekey_data(struct sk_buff *skb, struct genl_info *info) ...@@ -10393,10 +10385,9 @@ static int nl80211_set_rekey_data(struct sk_buff *skb, struct genl_info *info)
if (!info->attrs[NL80211_ATTR_REKEY_DATA]) if (!info->attrs[NL80211_ATTR_REKEY_DATA])
return -EINVAL; return -EINVAL;
err = nla_parse(tb, MAX_NL80211_REKEY_DATA, err = nla_parse_nested(tb, MAX_NL80211_REKEY_DATA,
nla_data(info->attrs[NL80211_ATTR_REKEY_DATA]), info->attrs[NL80211_ATTR_REKEY_DATA],
nla_len(info->attrs[NL80211_ATTR_REKEY_DATA]), nl80211_rekey_policy);
nl80211_rekey_policy);
if (err) if (err)
return err; return err;
...@@ -10705,10 +10696,9 @@ static int nl80211_nan_add_func(struct sk_buff *skb, ...@@ -10705,10 +10696,9 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
wdev->owner_nlportid != info->snd_portid) wdev->owner_nlportid != info->snd_portid)
return -ENOTCONN; return -ENOTCONN;
err = nla_parse(tb, NL80211_NAN_FUNC_ATTR_MAX, err = nla_parse_nested(tb, NL80211_NAN_FUNC_ATTR_MAX,
nla_data(info->attrs[NL80211_ATTR_NAN_FUNC]), info->attrs[NL80211_ATTR_NAN_FUNC],
nla_len(info->attrs[NL80211_ATTR_NAN_FUNC]), nl80211_nan_func_policy);
nl80211_nan_func_policy);
if (err) if (err)
return err; return err;
...@@ -10803,10 +10793,9 @@ static int nl80211_nan_add_func(struct sk_buff *skb, ...@@ -10803,10 +10793,9 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
if (tb[NL80211_NAN_FUNC_SRF]) { if (tb[NL80211_NAN_FUNC_SRF]) {
struct nlattr *srf_tb[NUM_NL80211_NAN_SRF_ATTR]; struct nlattr *srf_tb[NUM_NL80211_NAN_SRF_ATTR];
err = nla_parse(srf_tb, NL80211_NAN_SRF_ATTR_MAX, err = nla_parse_nested(srf_tb, NL80211_NAN_SRF_ATTR_MAX,
nla_data(tb[NL80211_NAN_FUNC_SRF]), tb[NL80211_NAN_FUNC_SRF],
nla_len(tb[NL80211_NAN_FUNC_SRF]), nl80211_nan_srf_policy);
nl80211_nan_srf_policy);
if (err) if (err)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment