diff mbox series

[v2] wifi: cfg80211: Use kmemdup_array instead of kmemdup for multiple allocation

Message ID 20240821111250.591558-1-yujiaoliang@vivo.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [v2] wifi: cfg80211: Use kmemdup_array instead of kmemdup for multiple allocation | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 16 this patch: 16
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yu Jiaoliang Aug. 21, 2024, 11:12 a.m. UTC
Let the kememdup_array() take care about multiplication and possible
overflows.

v2:
-Change sizeof(limits[0]) to sizeof(*limits)
-Fix title prefix

Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
Reviewed-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Kalle Valo <kvalo@kernel.org>
---
 net/wireless/util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Christophe JAILLET Aug. 21, 2024, 12:08 p.m. UTC | #1
Le 21/08/2024 à 13:12, Yu Jiaoliang a écrit :
> Let the kememdup_array() take care about multiplication and possible
> overflows.
> 
> v2:
> -Change sizeof(limits[0]) to sizeof(*limits)
> -Fix title prefix

Hi,

this kind of information about differences between versions is usually 
below the ---.

> 
> Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
> Reviewed-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

It is not because someone makes a comment on a patch that you should 
automatically add a R-b tag.

> Reviewed-by: Kalle Valo <kvalo@kernel.org>
> ---
>   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 9a7c3adc8a3b..e7c1ac2a0f2d 100644
> --- a/net/wireless/util.c
> +++ b/net/wireless/util.c
> @@ -2435,8 +2435,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;
>   

Reviewed-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Now you can add my R-b :).

CJ
Kalle Valo Aug. 21, 2024, 5:26 p.m. UTC | #2
Yu Jiaoliang <yujiaoliang@vivo.com> writes:

> Let the kememdup_array() take care about multiplication and possible
> overflows.
>
> v2:
> -Change sizeof(limits[0]) to sizeof(*limits)
> -Fix title prefix
>
> Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
> Reviewed-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> Reviewed-by: Kalle Valo <kvalo@kernel.org>

No, I did not review your patch. Do not add any tags (like Reviewed-by)
unless a person gives you that in a reply.
diff mbox series

Patch

diff --git a/net/wireless/util.c b/net/wireless/util.c
index 9a7c3adc8a3b..e7c1ac2a0f2d 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -2435,8 +2435,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;