Skip to content

Commit

Permalink
wifi: mac80211: use kmemdup_array instead of kmemdup for multiple all…
Browse files Browse the repository at this point in the history
…ocation

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 <[email protected]>
Reviewed-by: Michal Swiatkowski <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Johannes Berg <[email protected]>
  • Loading branch information
Shen Lichuan authored and jmberg-intel committed Aug 27, 2024
1 parent 32bf772 commit d07e1f5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net/mac80211/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit d07e1f5

Please sign in to comment.