Skip to content

Commit

Permalink
nl80211: Fix potential memory leak from parse_acl_data
Browse files Browse the repository at this point in the history
If parse_acl_data succeeds but the subsequent parsing of smps
attributes fails, there will be a memory leak due to early returns.
Fix that by moving the ACL parsing later.

Cc: [email protected]
Fixes: 18998c3 ("cfg80211: allow requesting SMPS mode on ap start")
Signed-off-by: Ola Olsson <[email protected]>
Signed-off-by: Johannes Berg <[email protected]>
  • Loading branch information
ola1olsson authored and jmberg-intel committed Nov 3, 2015
1 parent 519ee69 commit 4baf6be
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions net/wireless/nl80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -3432,12 +3432,6 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
wdev->iftype))
return -EINVAL;

if (info->attrs[NL80211_ATTR_ACL_POLICY]) {
params.acl = parse_acl_data(&rdev->wiphy, info);
if (IS_ERR(params.acl))
return PTR_ERR(params.acl);
}

if (info->attrs[NL80211_ATTR_SMPS_MODE]) {
params.smps_mode =
nla_get_u8(info->attrs[NL80211_ATTR_SMPS_MODE]);
Expand All @@ -3461,6 +3455,12 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
params.smps_mode = NL80211_SMPS_OFF;
}

if (info->attrs[NL80211_ATTR_ACL_POLICY]) {
params.acl = parse_acl_data(&rdev->wiphy, info);
if (IS_ERR(params.acl))
return PTR_ERR(params.acl);
}

wdev_lock(wdev);
err = rdev_start_ap(rdev, dev, &params);
if (!err) {
Expand Down

0 comments on commit 4baf6be

Please sign in to comment.