]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
wifi: mac80211: use kmemdup_array instead of kmemdup for multiple allocation
authorShen Lichuan <shenlichuan@vivo.com>
Tue, 27 Aug 2024 07:21:15 +0000 (15:21 +0800)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 27 Aug 2024 08:28:56 +0000 (10:28 +0200)
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>
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Link: https://patch.msgid.link/20240827072115.42680-1-shenlichuan@vivo.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/main.c

index a3104b6ea6f0b989d0b468f51de50304099ffc82..89084690350fd7cb6f7311298cd2497098384c2b 100644 (file)
@@ -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;