linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/4] clk: Switch to use kmemdup_array()
@ 2024-06-06 16:09 Andy Shevchenko
  2024-06-06 16:09 ` [PATCH v1 1/4] clk: mmp: " Andy Shevchenko
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Andy Shevchenko @ 2024-06-06 16:09 UTC (permalink / raw)
  To: Andy Shevchenko, Sam Protsenko, Krzysztof Kozlowski, linux-clk,
	linux-kernel, linux-arm-kernel, linux-rockchip, linux-samsung-soc
  Cc: Michael Turquette, Stephen Boyd, Heiko Stuebner,
	Krzysztof Kozlowski, Sylwester Nawrocki, Chanwoo Choi,
	Alim Akhtar, Nobuhiro Iwamatsu

Replace open coded kmemdup_array(), which does an additional
overflow check.

Andy Shevchenko (4):
  clk: mmp: Switch to use kmemdup_array()
  clk: rockchip: Switch to use kmemdup_array()
  clk: samsung: Switch to use kmemdup_array()
  clk: visconti: Switch to use kmemdup_array()

 drivers/clk/mmp/clk-mix.c      | 10 ++++------
 drivers/clk/rockchip/clk-cpu.c |  5 ++---
 drivers/clk/rockchip/clk-pll.c |  8 ++++----
 drivers/clk/samsung/clk-cpu.c  |  4 ++--
 drivers/clk/samsung/clk-pll.c  |  8 ++++----
 drivers/clk/visconti/pll.c     |  6 +++---
 6 files changed, 19 insertions(+), 22 deletions(-)

-- 
2.43.0.rc1.1336.g36b5255a03ac


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v1 1/4] clk: mmp: Switch to use kmemdup_array()
  2024-06-06 16:09 [PATCH v1 0/4] clk: Switch to use kmemdup_array() Andy Shevchenko
@ 2024-06-06 16:09 ` Andy Shevchenko
  2024-06-06 16:09 ` [PATCH v1 2/4] clk: rockchip: " Andy Shevchenko
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2024-06-06 16:09 UTC (permalink / raw)
  To: Andy Shevchenko, Sam Protsenko, Krzysztof Kozlowski, linux-clk,
	linux-kernel, linux-arm-kernel, linux-rockchip, linux-samsung-soc
  Cc: Michael Turquette, Stephen Boyd, Heiko Stuebner,
	Krzysztof Kozlowski, Sylwester Nawrocki, Chanwoo Choi,
	Alim Akhtar, Nobuhiro Iwamatsu

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/clk/mmp/clk-mix.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/mmp/clk-mix.c b/drivers/clk/mmp/clk-mix.c
index 454d131f475e..07ac9e6937e5 100644
--- a/drivers/clk/mmp/clk-mix.c
+++ b/drivers/clk/mmp/clk-mix.c
@@ -447,7 +447,6 @@ struct clk *mmp_clk_register_mix(struct device *dev,
 	struct mmp_clk_mix *mix;
 	struct clk *clk;
 	struct clk_init_data init;
-	size_t table_bytes;
 
 	mix = kzalloc(sizeof(*mix), GFP_KERNEL);
 	if (!mix)
@@ -461,8 +460,8 @@ struct clk *mmp_clk_register_mix(struct device *dev,
 
 	memcpy(&mix->reg_info, &config->reg_info, sizeof(config->reg_info));
 	if (config->table) {
-		table_bytes = sizeof(*config->table) * config->table_size;
-		mix->table = kmemdup(config->table, table_bytes, GFP_KERNEL);
+		mix->table = kmemdup_array(config->table, config->table_size,
+					   sizeof(*mix->table), GFP_KERNEL);
 		if (!mix->table)
 			goto free_mix;
 
@@ -470,9 +469,8 @@ struct clk *mmp_clk_register_mix(struct device *dev,
 	}
 
 	if (config->mux_table) {
-		table_bytes = sizeof(u32) * num_parents;
-		mix->mux_table = kmemdup(config->mux_table, table_bytes,
-					 GFP_KERNEL);
+		mix->mux_table = kmemdup_array(config->mux_table, num_parents,
+					       sizeof(*mix->mux_table), GFP_KERNEL);
 		if (!mix->mux_table) {
 			kfree(mix->table);
 			goto free_mix;
-- 
2.43.0.rc1.1336.g36b5255a03ac


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v1 2/4] clk: rockchip: Switch to use kmemdup_array()
  2024-06-06 16:09 [PATCH v1 0/4] clk: Switch to use kmemdup_array() Andy Shevchenko
  2024-06-06 16:09 ` [PATCH v1 1/4] clk: mmp: " Andy Shevchenko
@ 2024-06-06 16:09 ` Andy Shevchenko
  2024-06-07  8:13   ` Heiko Stübner
  2024-06-06 16:09 ` [PATCH v1 3/4] clk: samsung: " Andy Shevchenko
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Andy Shevchenko @ 2024-06-06 16:09 UTC (permalink / raw)
  To: Andy Shevchenko, Sam Protsenko, Krzysztof Kozlowski, linux-clk,
	linux-kernel, linux-arm-kernel, linux-rockchip, linux-samsung-soc
  Cc: Michael Turquette, Stephen Boyd, Heiko Stuebner,
	Krzysztof Kozlowski, Sylwester Nawrocki, Chanwoo Choi,
	Alim Akhtar, Nobuhiro Iwamatsu

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/clk/rockchip/clk-cpu.c | 5 ++---
 drivers/clk/rockchip/clk-pll.c | 8 ++++----
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/rockchip/clk-cpu.c b/drivers/clk/rockchip/clk-cpu.c
index 6ea7fba9f9e5..398a226ad34e 100644
--- a/drivers/clk/rockchip/clk-cpu.c
+++ b/drivers/clk/rockchip/clk-cpu.c
@@ -369,9 +369,8 @@ struct clk *rockchip_clk_register_cpuclk(const char *name,
 
 	if (nrates > 0) {
 		cpuclk->rate_count = nrates;
-		cpuclk->rate_table = kmemdup(rates,
-					     sizeof(*rates) * nrates,
-					     GFP_KERNEL);
+		cpuclk->rate_table = kmemdup_array(rates, nrates, sizeof(*rates),
+						   GFP_KERNEL);
 		if (!cpuclk->rate_table) {
 			ret = -ENOMEM;
 			goto unregister_notifier;
diff --git a/drivers/clk/rockchip/clk-pll.c b/drivers/clk/rockchip/clk-pll.c
index 2d42eb628926..606ce5458f54 100644
--- a/drivers/clk/rockchip/clk-pll.c
+++ b/drivers/clk/rockchip/clk-pll.c
@@ -1136,10 +1136,10 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,
 			len++;
 
 		pll->rate_count = len;
-		pll->rate_table = kmemdup(rate_table,
-					pll->rate_count *
-					sizeof(struct rockchip_pll_rate_table),
-					GFP_KERNEL);
+		pll->rate_table = kmemdup_array(rate_table,
+						pll->rate_count,
+						sizeof(*pll->rate_table),
+						GFP_KERNEL);
 		WARN(!pll->rate_table,
 			"%s: could not allocate rate table for %s\n",
 			__func__, name);
-- 
2.43.0.rc1.1336.g36b5255a03ac


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v1 3/4] clk: samsung: Switch to use kmemdup_array()
  2024-06-06 16:09 [PATCH v1 0/4] clk: Switch to use kmemdup_array() Andy Shevchenko
  2024-06-06 16:09 ` [PATCH v1 1/4] clk: mmp: " Andy Shevchenko
  2024-06-06 16:09 ` [PATCH v1 2/4] clk: rockchip: " Andy Shevchenko
@ 2024-06-06 16:09 ` Andy Shevchenko
  2024-06-16  7:24   ` (subset) " Krzysztof Kozlowski
  2024-06-06 16:09 ` [PATCH v1 4/4] clk: visconti: " Andy Shevchenko
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Andy Shevchenko @ 2024-06-06 16:09 UTC (permalink / raw)
  To: Andy Shevchenko, Sam Protsenko, Krzysztof Kozlowski, linux-clk,
	linux-kernel, linux-arm-kernel, linux-rockchip, linux-samsung-soc
  Cc: Michael Turquette, Stephen Boyd, Heiko Stuebner,
	Krzysztof Kozlowski, Sylwester Nawrocki, Chanwoo Choi,
	Alim Akhtar, Nobuhiro Iwamatsu

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/clk/samsung/clk-cpu.c | 4 ++--
 drivers/clk/samsung/clk-pll.c | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c
index fbf4c4208e06..dfa149e648aa 100644
--- a/drivers/clk/samsung/clk-cpu.c
+++ b/drivers/clk/samsung/clk-cpu.c
@@ -689,8 +689,8 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
 	for (num_cfgs = 0; clk_data->cfg[num_cfgs].prate != 0; )
 		num_cfgs++;
 
-	cpuclk->cfg = kmemdup(clk_data->cfg, sizeof(*clk_data->cfg) * num_cfgs,
-			      GFP_KERNEL);
+	cpuclk->cfg = kmemdup_array(clk_data->cfg, num_cfgs, sizeof(*cpuclk->cfg),
+				    GFP_KERNEL);
 	if (!cpuclk->cfg) {
 		ret = -ENOMEM;
 		goto unregister_clk_nb;
diff --git a/drivers/clk/samsung/clk-pll.c b/drivers/clk/samsung/clk-pll.c
index 4bbdf5e91650..4be879ab917e 100644
--- a/drivers/clk/samsung/clk-pll.c
+++ b/drivers/clk/samsung/clk-pll.c
@@ -1286,10 +1286,10 @@ static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx,
 			len++;
 
 		pll->rate_count = len;
-		pll->rate_table = kmemdup(pll_clk->rate_table,
-					pll->rate_count *
-					sizeof(struct samsung_pll_rate_table),
-					GFP_KERNEL);
+		pll->rate_table = kmemdup_array(pll_clk->rate_table,
+						pll->rate_count,
+						sizeof(*pll->rate_table),
+						GFP_KERNEL);
 		WARN(!pll->rate_table,
 			"%s: could not allocate rate table for %s\n",
 			__func__, pll_clk->name);
-- 
2.43.0.rc1.1336.g36b5255a03ac


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v1 4/4] clk: visconti: Switch to use kmemdup_array()
  2024-06-06 16:09 [PATCH v1 0/4] clk: Switch to use kmemdup_array() Andy Shevchenko
                   ` (2 preceding siblings ...)
  2024-06-06 16:09 ` [PATCH v1 3/4] clk: samsung: " Andy Shevchenko
@ 2024-06-06 16:09 ` Andy Shevchenko
  2024-06-16  7:59 ` (subset) [PATCH v1 0/4] clk: " Heiko Stuebner
  2024-08-13  8:37 ` Andy Shevchenko
  5 siblings, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2024-06-06 16:09 UTC (permalink / raw)
  To: Andy Shevchenko, Sam Protsenko, Krzysztof Kozlowski, linux-clk,
	linux-kernel, linux-arm-kernel, linux-rockchip, linux-samsung-soc
  Cc: Michael Turquette, Stephen Boyd, Heiko Stuebner,
	Krzysztof Kozlowski, Sylwester Nawrocki, Chanwoo Choi,
	Alim Akhtar, Nobuhiro Iwamatsu

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/clk/visconti/pll.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/visconti/pll.c b/drivers/clk/visconti/pll.c
index e9cd80e085dc..3f929cf8dd2f 100644
--- a/drivers/clk/visconti/pll.c
+++ b/drivers/clk/visconti/pll.c
@@ -262,9 +262,9 @@ static struct clk_hw *visconti_register_pll(struct visconti_pll_provider *ctx,
 	for (len = 0; rate_table[len].rate != 0; )
 		len++;
 	pll->rate_count = len;
-	pll->rate_table = kmemdup(rate_table,
-				  pll->rate_count * sizeof(struct visconti_pll_rate_table),
-				  GFP_KERNEL);
+	pll->rate_table = kmemdup_array(rate_table,
+					pll->rate_count, sizeof(*pll->rate_table),
+					GFP_KERNEL);
 	WARN(!pll->rate_table, "%s: could not allocate rate table for %s\n", __func__, name);
 
 	init.ops = &visconti_pll_ops;
-- 
2.43.0.rc1.1336.g36b5255a03ac


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v1 2/4] clk: rockchip: Switch to use kmemdup_array()
  2024-06-06 16:09 ` [PATCH v1 2/4] clk: rockchip: " Andy Shevchenko
@ 2024-06-07  8:13   ` Heiko Stübner
  2024-06-11 13:20     ` Andy Shevchenko
  0 siblings, 1 reply; 13+ messages in thread
From: Heiko Stübner @ 2024-06-07  8:13 UTC (permalink / raw)
  To: Andy Shevchenko, Sam Protsenko, Krzysztof Kozlowski, linux-clk,
	linux-kernel, linux-arm-kernel, linux-rockchip, linux-samsung-soc,
	Andy Shevchenko
  Cc: Michael Turquette, Stephen Boyd, Krzysztof Kozlowski,
	Sylwester Nawrocki, Chanwoo Choi, Alim Akhtar, Nobuhiro Iwamatsu

Hi Andy,

Am Donnerstag, 6. Juni 2024, 18:09:32 CEST schrieb Andy Shevchenko:
> Let the kememdup_array() take care about multiplication and possible
> overflows.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/clk/rockchip/clk-cpu.c | 5 ++---
>  drivers/clk/rockchip/clk-pll.c | 8 ++++----
>  2 files changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/clk/rockchip/clk-cpu.c b/drivers/clk/rockchip/clk-cpu.c
> index 6ea7fba9f9e5..398a226ad34e 100644
> --- a/drivers/clk/rockchip/clk-cpu.c
> +++ b/drivers/clk/rockchip/clk-cpu.c
> @@ -369,9 +369,8 @@ struct clk *rockchip_clk_register_cpuclk(const char *name,
>  
>  	if (nrates > 0) {
>  		cpuclk->rate_count = nrates;
> -		cpuclk->rate_table = kmemdup(rates,
> -					     sizeof(*rates) * nrates,
> -					     GFP_KERNEL);
> +		cpuclk->rate_table = kmemdup_array(rates, nrates, sizeof(*rates),
> +						   GFP_KERNEL);

are you sure the param order is correct?

According to [0], it's (src, element_size, count, gfp), while above
(and below) element_size and count seems switched in the
kmemdup_array calls.


Heiko

[0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/util.c#n149

>  		if (!cpuclk->rate_table) {
>  			ret = -ENOMEM;
>  			goto unregister_notifier;
> diff --git a/drivers/clk/rockchip/clk-pll.c b/drivers/clk/rockchip/clk-pll.c
> index 2d42eb628926..606ce5458f54 100644
> --- a/drivers/clk/rockchip/clk-pll.c
> +++ b/drivers/clk/rockchip/clk-pll.c
> @@ -1136,10 +1136,10 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,
>  			len++;
>  
>  		pll->rate_count = len;
> -		pll->rate_table = kmemdup(rate_table,
> -					pll->rate_count *
> -					sizeof(struct rockchip_pll_rate_table),
> -					GFP_KERNEL);
> +		pll->rate_table = kmemdup_array(rate_table,
> +						pll->rate_count,
> +						sizeof(*pll->rate_table),
> +						GFP_KERNEL);
>  		WARN(!pll->rate_table,
>  			"%s: could not allocate rate table for %s\n",
>  			__func__, name);
> 





_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v1 2/4] clk: rockchip: Switch to use kmemdup_array()
  2024-06-07  8:13   ` Heiko Stübner
@ 2024-06-11 13:20     ` Andy Shevchenko
  2024-06-16  8:00       ` Heiko Stuebner
  0 siblings, 1 reply; 13+ messages in thread
From: Andy Shevchenko @ 2024-06-11 13:20 UTC (permalink / raw)
  To: Heiko Stübner
  Cc: Sam Protsenko, Krzysztof Kozlowski, linux-clk, linux-kernel,
	linux-arm-kernel, linux-rockchip, linux-samsung-soc,
	Michael Turquette, Stephen Boyd, Krzysztof Kozlowski,
	Sylwester Nawrocki, Chanwoo Choi, Alim Akhtar, Nobuhiro Iwamatsu

On Fri, Jun 07, 2024 at 10:13:04AM +0200, Heiko Stübner wrote:
> Am Donnerstag, 6. Juni 2024, 18:09:32 CEST schrieb Andy Shevchenko:

...

> > -		cpuclk->rate_table = kmemdup(rates,
> > -					     sizeof(*rates) * nrates,
> > -					     GFP_KERNEL);
> > +		cpuclk->rate_table = kmemdup_array(rates, nrates, sizeof(*rates),
> > +						   GFP_KERNEL);
> 
> are you sure the param order is correct?
> 
> According to [0], it's (src, element_size, count, gfp), while above
> (and below) element_size and count seems switched in the
> kmemdup_array calls.

I'm glad you asked. The parameter order is going to be fixed [1].

> [0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/util.c#n149

[1]: 0ee14725471c ("mm/util: Swap kmemdup_array() arguments")

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: (subset) [PATCH v1 3/4] clk: samsung: Switch to use kmemdup_array()
  2024-06-06 16:09 ` [PATCH v1 3/4] clk: samsung: " Andy Shevchenko
@ 2024-06-16  7:24   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-16  7:24 UTC (permalink / raw)
  To: Sam Protsenko, linux-clk, linux-kernel, linux-arm-kernel,
	linux-rockchip, linux-samsung-soc, Andy Shevchenko
  Cc: Michael Turquette, Stephen Boyd, Heiko Stuebner,
	Krzysztof Kozlowski, Sylwester Nawrocki, Chanwoo Choi,
	Alim Akhtar, Nobuhiro Iwamatsu


On Thu, 06 Jun 2024 19:09:33 +0300, Andy Shevchenko wrote:
> Let the kememdup_array() take care about multiplication and possible
> overflows.
> 
> 

Applied, thanks!

[3/4] clk: samsung: Switch to use kmemdup_array()
      https://git.kernel.org/krzk/linux/c/7666718892f2a8582127f584fdbf5dada59af2d8

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>



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

* Re: (subset) [PATCH v1 0/4] clk: Switch to use kmemdup_array()
  2024-06-06 16:09 [PATCH v1 0/4] clk: Switch to use kmemdup_array() Andy Shevchenko
                   ` (3 preceding siblings ...)
  2024-06-06 16:09 ` [PATCH v1 4/4] clk: visconti: " Andy Shevchenko
@ 2024-06-16  7:59 ` Heiko Stuebner
  2024-08-13  8:37 ` Andy Shevchenko
  5 siblings, 0 replies; 13+ messages in thread
From: Heiko Stuebner @ 2024-06-16  7:59 UTC (permalink / raw)
  To: Andy Shevchenko, linux-rockchip, Sam Protsenko, linux-samsung-soc,
	linux-kernel, linux-clk, linux-arm-kernel, Krzysztof Kozlowski
  Cc: Heiko Stuebner, Michael Turquette, Krzysztof Kozlowski,
	Alim Akhtar, Nobuhiro Iwamatsu, Chanwoo Choi, Stephen Boyd,
	Sylwester Nawrocki

On Thu, 6 Jun 2024 19:09:30 +0300, Andy Shevchenko wrote:
> Replace open coded kmemdup_array(), which does an additional
> overflow check.
> 
> Andy Shevchenko (4):
>   clk: mmp: Switch to use kmemdup_array()
>   clk: rockchip: Switch to use kmemdup_array()
>   clk: samsung: Switch to use kmemdup_array()
>   clk: visconti: Switch to use kmemdup_array()
> 
> [...]

Applied, thanks!

[2/4] clk: rockchip: Switch to use kmemdup_array()
      commit: c9ba07b0c02acd89f2e521754357de30e704c254

Best regards,
-- 
Heiko Stuebner <heiko@sntech.de>


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

* Re: [PATCH v1 2/4] clk: rockchip: Switch to use kmemdup_array()
  2024-06-11 13:20     ` Andy Shevchenko
@ 2024-06-16  8:00       ` Heiko Stuebner
  0 siblings, 0 replies; 13+ messages in thread
From: Heiko Stuebner @ 2024-06-16  8:00 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Sam Protsenko, Krzysztof Kozlowski, linux-clk, linux-kernel,
	linux-arm-kernel, linux-rockchip, linux-samsung-soc,
	Michael Turquette, Stephen Boyd, Krzysztof Kozlowski,
	Sylwester Nawrocki, Chanwoo Choi, Alim Akhtar, Nobuhiro Iwamatsu

Am Dienstag, 11. Juni 2024, 15:20:05 CEST schrieb Andy Shevchenko:
> On Fri, Jun 07, 2024 at 10:13:04AM +0200, Heiko Stübner wrote:
> > Am Donnerstag, 6. Juni 2024, 18:09:32 CEST schrieb Andy Shevchenko:
> 
> ...
> 
> > > -		cpuclk->rate_table = kmemdup(rates,
> > > -					     sizeof(*rates) * nrates,
> > > -					     GFP_KERNEL);
> > > +		cpuclk->rate_table = kmemdup_array(rates, nrates, sizeof(*rates),
> > > +						   GFP_KERNEL);
> > 
> > are you sure the param order is correct?
> > 
> > According to [0], it's (src, element_size, count, gfp), while above
> > (and below) element_size and count seems switched in the
> > kmemdup_array calls.
> 
> I'm glad you asked. The parameter order is going to be fixed [1].
> 
> > [0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/util.c#n149
> 
> [1]: 0ee14725471c ("mm/util: Swap kmemdup_array() arguments")

ah that clears it up :-)


Thanks for the pointer
Heiko




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

* Re: [PATCH v1 0/4] clk: Switch to use kmemdup_array()
  2024-06-06 16:09 [PATCH v1 0/4] clk: Switch to use kmemdup_array() Andy Shevchenko
                   ` (4 preceding siblings ...)
  2024-06-16  7:59 ` (subset) [PATCH v1 0/4] clk: " Heiko Stuebner
@ 2024-08-13  8:37 ` Andy Shevchenko
  2024-08-14  0:01   ` Stephen Boyd
  5 siblings, 1 reply; 13+ messages in thread
From: Andy Shevchenko @ 2024-08-13  8:37 UTC (permalink / raw)
  To: Sam Protsenko, Krzysztof Kozlowski, linux-clk, linux-kernel,
	linux-arm-kernel, linux-rockchip, linux-samsung-soc
  Cc: Michael Turquette, Stephen Boyd, Heiko Stuebner,
	Krzysztof Kozlowski, Sylwester Nawrocki, Chanwoo Choi,
	Alim Akhtar, Nobuhiro Iwamatsu

On Thu, Jun 06, 2024 at 07:09:30PM +0300, Andy Shevchenko wrote:
> Replace open coded kmemdup_array(), which does an additional
> overflow check.

...

>   clk: mmp: Switch to use kmemdup_array()

>   clk: visconti: Switch to use kmemdup_array()

Any news for these two?

-- 
With Best Regards,
Andy Shevchenko




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

* Re: [PATCH v1 0/4] clk: Switch to use kmemdup_array()
  2024-08-13  8:37 ` Andy Shevchenko
@ 2024-08-14  0:01   ` Stephen Boyd
  2024-08-14 12:55     ` Andy Shevchenko
  0 siblings, 1 reply; 13+ messages in thread
From: Stephen Boyd @ 2024-08-14  0:01 UTC (permalink / raw)
  To: Andy Shevchenko, Krzysztof Kozlowski, Sam Protsenko,
	linux-arm-kernel, linux-clk, linux-kernel, linux-rockchip,
	linux-samsung-soc
  Cc: Michael Turquette, Heiko Stuebner, Krzysztof Kozlowski,
	Sylwester Nawrocki, Chanwoo Choi, Alim Akhtar, Nobuhiro Iwamatsu

Quoting Andy Shevchenko (2024-08-13 01:37:48)
> On Thu, Jun 06, 2024 at 07:09:30PM +0300, Andy Shevchenko wrote:
> > Replace open coded kmemdup_array(), which does an additional
> > overflow check.
> 
> ...
> 
> >   clk: mmp: Switch to use kmemdup_array()
> 
> >   clk: visconti: Switch to use kmemdup_array()

I have them all as "changes requested" so please resend.


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

* Re: [PATCH v1 0/4] clk: Switch to use kmemdup_array()
  2024-08-14  0:01   ` Stephen Boyd
@ 2024-08-14 12:55     ` Andy Shevchenko
  0 siblings, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2024-08-14 12:55 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Krzysztof Kozlowski, Sam Protsenko, linux-arm-kernel, linux-clk,
	linux-kernel, linux-rockchip, linux-samsung-soc,
	Michael Turquette, Heiko Stuebner, Krzysztof Kozlowski,
	Sylwester Nawrocki, Chanwoo Choi, Alim Akhtar, Nobuhiro Iwamatsu

On Tue, Aug 13, 2024 at 05:01:50PM -0700, Stephen Boyd wrote:
> Quoting Andy Shevchenko (2024-08-13 01:37:48)
> > On Thu, Jun 06, 2024 at 07:09:30PM +0300, Andy Shevchenko wrote:

...

> > >   clk: mmp: Switch to use kmemdup_array()
> > 
> > >   clk: visconti: Switch to use kmemdup_array()
> 
> I have them all as "changes requested" so please resend.

Done (Message-Id: 20240814125513.2637955-1-andriy.shevchenko@linux.intel.com).

-- 
With Best Regards,
Andy Shevchenko




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

end of thread, other threads:[~2024-08-14 12:58 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-06 16:09 [PATCH v1 0/4] clk: Switch to use kmemdup_array() Andy Shevchenko
2024-06-06 16:09 ` [PATCH v1 1/4] clk: mmp: " Andy Shevchenko
2024-06-06 16:09 ` [PATCH v1 2/4] clk: rockchip: " Andy Shevchenko
2024-06-07  8:13   ` Heiko Stübner
2024-06-11 13:20     ` Andy Shevchenko
2024-06-16  8:00       ` Heiko Stuebner
2024-06-06 16:09 ` [PATCH v1 3/4] clk: samsung: " Andy Shevchenko
2024-06-16  7:24   ` (subset) " Krzysztof Kozlowski
2024-06-06 16:09 ` [PATCH v1 4/4] clk: visconti: " Andy Shevchenko
2024-06-16  7:59 ` (subset) [PATCH v1 0/4] clk: " Heiko Stuebner
2024-08-13  8:37 ` Andy Shevchenko
2024-08-14  0:01   ` Stephen Boyd
2024-08-14 12:55     ` Andy Shevchenko

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).