Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nl80211: Fix potential memory leak from parse_acl_data

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: stable@vger.kernel.org
Fixes: 18998c381b19b ("cfg80211: allow requesting SMPS mode on ap start")
Signed-off-by: Ola Olsson <ola.olsson@sonymobile.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Ola Olsson and committed by
Johannes Berg
4baf6bea 519ee691

+6 -6
+6 -6
net/wireless/nl80211.c
··· 3432 3432 wdev->iftype)) 3433 3433 return -EINVAL; 3434 3434 3435 - if (info->attrs[NL80211_ATTR_ACL_POLICY]) { 3436 - params.acl = parse_acl_data(&rdev->wiphy, info); 3437 - if (IS_ERR(params.acl)) 3438 - return PTR_ERR(params.acl); 3439 - } 3440 - 3441 3435 if (info->attrs[NL80211_ATTR_SMPS_MODE]) { 3442 3436 params.smps_mode = 3443 3437 nla_get_u8(info->attrs[NL80211_ATTR_SMPS_MODE]); ··· 3453 3459 } 3454 3460 } else { 3455 3461 params.smps_mode = NL80211_SMPS_OFF; 3462 + } 3463 + 3464 + if (info->attrs[NL80211_ATTR_ACL_POLICY]) { 3465 + params.acl = parse_acl_data(&rdev->wiphy, info); 3466 + if (IS_ERR(params.acl)) 3467 + return PTR_ERR(params.acl); 3456 3468 } 3457 3469 3458 3470 wdev_lock(wdev);