Skip to content

Commit

Permalink
nl80211: Handle nla_memdup failures in handle_nan_filter
Browse files Browse the repository at this point in the history
[ Upstream commit 6ad27f5 ]

As there's potential for failure of the nla_memdup(),
check the return value.

Fixes: a442b76 ("cfg80211: add add_nan_func / del_nan_func")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20220301100020.3801187-1-jiasheng@iscas.ac.cn
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
JiangJias authored and gregkh committed Mar 8, 2022
1 parent a304966 commit a1e603e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions net/wireless/nl80211.c
Expand Up @@ -13177,6 +13177,9 @@ static int handle_nan_filter(struct nlattr *attr_filter,
i = 0;
nla_for_each_nested(attr, attr_filter, rem) {
filter[i].filter = nla_memdup(attr, GFP_KERNEL);
if (!filter[i].filter)
goto err;

filter[i].len = nla_len(attr);
i++;
}
Expand All @@ -13189,6 +13192,15 @@ static int handle_nan_filter(struct nlattr *attr_filter,
}

return 0;

err:
i = 0;
nla_for_each_nested(attr, attr_filter, rem) {
kfree(filter[i].filter);
i++;
}
kfree(filter);
return -ENOMEM;
}

static int nl80211_nan_add_func(struct sk_buff *skb,
Expand Down

0 comments on commit a1e603e

Please sign in to comment.