提交 d7ec5ed7 编写于 作者: J Jiasheng Jiang 提交者: Zheng Zengkai

nl80211: Handle nla_memdup failures in handle_nan_filter

stable inclusion
from stable-v5.10.104
commit f5e496ef73f307bef4d4f14edb45512d4d245954
bugzilla: https://gitee.com/openeuler/kernel/issues/I56XAC

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f5e496ef73f307bef4d4f14edb45512d4d245954

--------------------------------

[ Upstream commit 6ad27f52 ]

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

Fixes: a442b761 ("cfg80211: add add_nan_func / del_nan_func")
Signed-off-by: NJiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20220301100020.3801187-1-jiasheng@iscas.ac.cnSigned-off-by: NJohannes Berg <johannes.berg@intel.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYu Liao <liaoyu15@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 42d069a9
......@@ -12930,6 +12930,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++;
}
......@@ -12942,6 +12945,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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册