From 32bf7729d2e67aed4a6c537bf21d2023e3f39c45 Mon Sep 17 00:00:00 2001 From: Yu Jiaoliang Date: Thu, 22 Aug 2024 15:47:43 +0800 Subject: [PATCH] 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 Reviewed-by: Christophe JAILLET Link: https://patch.msgid.link/20240822074743.1366561-1-yujiaoliang@vivo.com Signed-off-by: Johannes Berg --- net/wireless/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/wireless/util.c b/net/wireless/util.c index edeeb056fe4d..f49b55724f83 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -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;