netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] wifi: mac80211: use kmemdup_array instead of kmemdup for multiple allocation
@ 2024-08-27  3:56 Shen Lichuan
  2024-08-27  6:55 ` Michal Swiatkowski
  0 siblings, 1 reply; 2+ messages in thread
From: Shen Lichuan @ 2024-08-27  3:56 UTC (permalink / raw)
  To: johannes, davem, edumazet, kuba, pabeni
  Cc: linux-wireless, netdev, linux-kernel, opensource.kernel,
	Shen Lichuan

Let the kmemdup_array() take care about multiplication
and possible overflows.

Using kmemdup_array() is more appropriate and makes the code
easier to audit.

Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
---
 net/mac80211/main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index a3104b6ea6f0..f16ebad36a83 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -1051,9 +1051,9 @@ static int ieee80211_init_cipher_suites(struct ieee80211_local *local)
 			return 0;
 
 		/* Driver provides cipher suites, but we need to exclude WEP */
-		suites = kmemdup(local->hw.wiphy->cipher_suites,
-				 sizeof(u32) * local->hw.wiphy->n_cipher_suites,
-				 GFP_KERNEL);
+		suites = kmemdup_array(local->hw.wiphy->cipher_suites,
+				       local->hw.wiphy->n_cipher_suites, sizeof(u32),
+				       GFP_KERNEL);
 		if (!suites)
 			return -ENOMEM;
 
-- 
2.17.1


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

end of thread, other threads:[~2024-08-27  6:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-27  3:56 [PATCH v1] wifi: mac80211: use kmemdup_array instead of kmemdup for multiple allocation Shen Lichuan
2024-08-27  6:55 ` Michal Swiatkowski

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).