linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wireless/nl80211: Handle errors for nla_memdup
@ 2022-03-01 10:00 Jiasheng Jiang
  2022-03-01 14:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2022-03-01 10:00 UTC (permalink / raw)
  To: johannes, davem, kuba
  Cc: linux-wireless, netdev, linux-kernel, Jiasheng Jiang

As the potential failure of the nla_memdup(),
it should be better to check it, as same as kmemdup().

Fixes: a442b761b24b ("cfg80211: add add_nan_func / del_nan_func")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 net/wireless/nl80211.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 578bff9c378b..b1909ce2b739 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -13411,6 +13411,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++;
 	}
@@ -13423,6 +13426,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,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] wireless/nl80211: Handle errors for nla_memdup
  2022-03-01 10:00 [PATCH] wireless/nl80211: Handle errors for nla_memdup Jiasheng Jiang
@ 2022-03-01 14:50 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-01 14:50 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: johannes, davem, kuba, linux-wireless, netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (master)
by Johannes Berg <johannes.berg@intel.com>:

On Tue,  1 Mar 2022 18:00:20 +0800 you wrote:
> As the potential failure of the nla_memdup(),
> it should be better to check it, as same as kmemdup().
> 
> Fixes: a442b761b24b ("cfg80211: add add_nan_func / del_nan_func")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>  net/wireless/nl80211.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)

Here is the summary with links:
  - wireless/nl80211: Handle errors for nla_memdup
    https://git.kernel.org/netdev/net/c/6ad27f522cb3

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-01 14:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01 10:00 [PATCH] wireless/nl80211: Handle errors for nla_memdup Jiasheng Jiang
2022-03-01 14:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).