netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] net: wireless: Use kmemdup_array instead of kmemdup for multiple allocation
@ 2024-08-21  7:20 Yu Jiaoliang
  0 siblings, 0 replies; 4+ messages in thread
From: Yu Jiaoliang @ 2024-08-21  7:20 UTC (permalink / raw)
  To: Johannes Berg, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, linux-wireless, netdev, linux-kernel
  Cc: opens^Crce.kernel

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

Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
---
 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..6cf19dda5d2a 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[0]),
+				       GFP_KERNEL);
 		if (!limits)
 			return -ENOMEM;
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v1] net: wireless: Use kmemdup_array instead of kmemdup for multiple allocation
@ 2024-08-21  7:24 Yu Jiaoliang
  2024-08-21  9:38 ` Christophe JAILLET
  2024-08-21 10:05 ` Kalle Valo
  0 siblings, 2 replies; 4+ messages in thread
From: Yu Jiaoliang @ 2024-08-21  7:24 UTC (permalink / raw)
  To: Johannes Berg, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, linux-wireless, netdev, linux-kernel
  Cc: opensource.kernel

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

Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
---
 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..6cf19dda5d2a 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[0]),
+				       GFP_KERNEL);
 		if (!limits)
 			return -ENOMEM;
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] net: wireless: Use kmemdup_array instead of kmemdup for multiple allocation
  2024-08-21  7:24 [PATCH v1] net: wireless: Use kmemdup_array instead of kmemdup for multiple allocation Yu Jiaoliang
@ 2024-08-21  9:38 ` Christophe JAILLET
  2024-08-21 10:05 ` Kalle Valo
  1 sibling, 0 replies; 4+ messages in thread
From: Christophe JAILLET @ 2024-08-21  9:38 UTC (permalink / raw)
  To: Yu Jiaoliang, Johannes Berg, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, linux-wireless, netdev, linux-kernel
  Cc: opensource.kernel

Le 21/08/2024 à 09:24, Yu Jiaoliang a écrit :
> Let the kememdup_array() take care about multiplication and possible
> overflows.
> 
> Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
> ---
>   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..6cf19dda5d2a 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[0]),

Maybe sizeof(*limits) would be a more usual pattern?

CJ

> +				       GFP_KERNEL);
>   		if (!limits)
>   			return -ENOMEM;
>   


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] net: wireless: Use kmemdup_array instead of kmemdup for multiple allocation
  2024-08-21  7:24 [PATCH v1] net: wireless: Use kmemdup_array instead of kmemdup for multiple allocation Yu Jiaoliang
  2024-08-21  9:38 ` Christophe JAILLET
@ 2024-08-21 10:05 ` Kalle Valo
  1 sibling, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2024-08-21 10:05 UTC (permalink / raw)
  To: Yu Jiaoliang
  Cc: Johannes Berg, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, linux-wireless, netdev, linux-kernel,
	opensource.kernel

Yu Jiaoliang <yujiaoliang@vivo.com> writes:

> Let the kememdup_array() take care about multiplication and possible
> overflows.
>
> Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
> ---
>  net/wireless/util.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

The title prefix should be "wifi: cfg80211:".

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-21 11:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-21  7:24 [PATCH v1] net: wireless: Use kmemdup_array instead of kmemdup for multiple allocation Yu Jiaoliang
2024-08-21  9:38 ` Christophe JAILLET
2024-08-21 10:05 ` Kalle Valo
  -- strict thread matches above, loose matches on Subject: below --
2024-08-21  7:20 Yu Jiaoliang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).