Linux-Clk Archive on lore.kernel.org
 help / Atom feed
* [PATCH] clk: zynqmp: Fix memory allocation in zynqmp_clk_setup
@ 2018-12-24  5:50 Gustavo A. R. Silva
  2019-01-03 11:00 ` Michal Simek
  2019-01-09 18:38 ` Stephen Boyd
  0 siblings, 2 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2018-12-24  5:50 UTC (permalink / raw)
  To: Jolly Shah, Michael Turquette, Stephen Boyd, Michal Simek
  Cc: linux-clk, linux-arm-kernel, linux-kernel, Gustavo A. R. Silva

Fix memory allocation and use struct_size() in kzalloc().

Fixes: 3fde0e16d016 ("drivers: clk: Add ZynqMP clock driver")
Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/clk/zynqmp/clkc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c
index f65cc0ff76ab..b0908ec62f73 100644
--- a/drivers/clk/zynqmp/clkc.c
+++ b/drivers/clk/zynqmp/clkc.c
@@ -669,8 +669,8 @@ static int zynqmp_clk_setup(struct device_node *np)
 	if (ret)
 		return ret;
 
-	zynqmp_data = kzalloc(sizeof(*zynqmp_data) + sizeof(*zynqmp_data) *
-						clock_max_idx, GFP_KERNEL);
+	zynqmp_data = kzalloc(struct_size(zynqmp_data, hws, clock_max_idx),
+			      GFP_KERNEL);
 	if (!zynqmp_data)
 		return -ENOMEM;
 
-- 
2.17.0


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

* Re: [PATCH] clk: zynqmp: Fix memory allocation in zynqmp_clk_setup
  2018-12-24  5:50 [PATCH] clk: zynqmp: Fix memory allocation in zynqmp_clk_setup Gustavo A. R. Silva
@ 2019-01-03 11:00 ` Michal Simek
  2019-01-09 18:38 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Simek @ 2019-01-03 11:00 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Jolly Shah, Michael Turquette, Stephen Boyd,
	Michal Simek
  Cc: linux-clk, linux-arm-kernel, linux-kernel

On 24. 12. 18 6:50, Gustavo A. R. Silva wrote:
> Fix memory allocation and use struct_size() in kzalloc().
> 
> Fixes: 3fde0e16d016 ("drivers: clk: Add ZynqMP clock driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
>  drivers/clk/zynqmp/clkc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c
> index f65cc0ff76ab..b0908ec62f73 100644
> --- a/drivers/clk/zynqmp/clkc.c
> +++ b/drivers/clk/zynqmp/clkc.c
> @@ -669,8 +669,8 @@ static int zynqmp_clk_setup(struct device_node *np)
>  	if (ret)
>  		return ret;
>  
> -	zynqmp_data = kzalloc(sizeof(*zynqmp_data) + sizeof(*zynqmp_data) *
> -						clock_max_idx, GFP_KERNEL);
> +	zynqmp_data = kzalloc(struct_size(zynqmp_data, hws, clock_max_idx),
> +			      GFP_KERNEL);
>  	if (!zynqmp_data)
>  		return -ENOMEM;
>  
> 

Looks good. Description could be maybe more verbose that you are fixing
issue that it should be sizeof(struct clk_hw) instead of sizeof(struct
clk_hw_onecell_data)
Otherwise
Acked-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal

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

* Re: [PATCH] clk: zynqmp: Fix memory allocation in zynqmp_clk_setup
  2018-12-24  5:50 [PATCH] clk: zynqmp: Fix memory allocation in zynqmp_clk_setup Gustavo A. R. Silva
  2019-01-03 11:00 ` Michal Simek
@ 2019-01-09 18:38 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2019-01-09 18:38 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Jolly Shah, Michael Turquette, Michal Simek
  Cc: linux-clk, linux-arm-kernel, linux-kernel, Gustavo A. R. Silva

Quoting Gustavo A. R. Silva (2018-12-23 21:50:58)
> Fix memory allocation and use struct_size() in kzalloc().
> 
> Fixes: 3fde0e16d016 ("drivers: clk: Add ZynqMP clock driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---

Applied to clk-fixes

And I added some words to commit text.

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-24  5:50 [PATCH] clk: zynqmp: Fix memory allocation in zynqmp_clk_setup Gustavo A. R. Silva
2019-01-03 11:00 ` Michal Simek
2019-01-09 18:38 ` Stephen Boyd

Linux-Clk Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-clk/0 linux-clk/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-clk linux-clk/ https://lore.kernel.org/linux-clk \
		linux-clk@vger.kernel.org linux-clk@archiver.kernel.org
	public-inbox-index linux-clk


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-clk


AGPL code for this site: git clone https://public-inbox.org/ public-inbox