wifi: cfg80211: Use kmemdup_array instead of kmemdup for multiple allocation

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

Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
Reviewed-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/20240822074743.1366561-1-yujiaoliang@vivo.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Yu Jiaoliang 2024-08-22 15:47:43 +08:00 committed by Johannes Berg
parent 76364f3edf
commit 32bf7729d2

View File

@ -2437,8 +2437,8 @@ int cfg80211_iter_combinations(struct wiphy *wiphy,
if (params->num_different_channels > c->num_different_channels)
continue;
limits = kmemdup(c->limits, sizeof(limits[0]) * c->n_limits,
GFP_KERNEL);
limits = kmemdup_array(c->limits, c->n_limits, sizeof(*limits),
GFP_KERNEL);
if (!limits)
return -ENOMEM;