linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: mediatek: clk-mt2701: Add check for mtk_alloc_clk_data
@ 2023-09-01  2:46 Jiasheng Jiang
  2023-09-04  9:48 ` Markus Schneider-Pargmann
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jiasheng Jiang @ 2023-09-01  2:46 UTC (permalink / raw)
  To: mturquette, sboyd, matthias.bgg, angelogioacchino.delregno, wenst,
	msp, frank.li, robh, jamesjj.liao, shunli.wang, erin.lo
  Cc: linux-clk, linux-kernel, linux-arm-kernel, linux-mediatek,
	Jiasheng Jiang

Add the check for the return value of mtk_alloc_clk_data() in order to
avoid NULL pointer dereference.

Fixes: e9862118272a ("clk: mediatek: Add MT2701 clock support")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/clk/mediatek/clk-mt2701.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/clk/mediatek/clk-mt2701.c b/drivers/clk/mediatek/clk-mt2701.c
index c81f3e33ce56..12d9560eb4ba 100644
--- a/drivers/clk/mediatek/clk-mt2701.c
+++ b/drivers/clk/mediatek/clk-mt2701.c
@@ -667,6 +667,8 @@ static int mtk_topckgen_init(struct platform_device *pdev)
 		return PTR_ERR(base);
 
 	clk_data = mtk_alloc_clk_data(CLK_TOP_NR);
+	if (!clk_data)
+		return -ENOMEM;
 
 	mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
 								clk_data);
@@ -747,6 +749,8 @@ static void __init mtk_infrasys_init_early(struct device_node *node)
 
 	if (!infra_clk_data) {
 		infra_clk_data = mtk_alloc_clk_data(CLK_INFRA_NR);
+		if (!infra_clk_data)
+			return;
 
 		for (i = 0; i < CLK_INFRA_NR; i++)
 			infra_clk_data->hws[i] = ERR_PTR(-EPROBE_DEFER);
@@ -774,6 +778,8 @@ static int mtk_infrasys_init(struct platform_device *pdev)
 
 	if (!infra_clk_data) {
 		infra_clk_data = mtk_alloc_clk_data(CLK_INFRA_NR);
+		if (!infra_clk_data)
+			return -ENOMEM;
 	} else {
 		for (i = 0; i < CLK_INFRA_NR; i++) {
 			if (infra_clk_data->hws[i] == ERR_PTR(-EPROBE_DEFER))
@@ -890,6 +896,8 @@ static int mtk_pericfg_init(struct platform_device *pdev)
 		return PTR_ERR(base);
 
 	clk_data = mtk_alloc_clk_data(CLK_PERI_NR);
+	if (!clk_data)
+		return -ENOMEM;
 
 	mtk_clk_register_gates(&pdev->dev, node, peri_clks,
 			       ARRAY_SIZE(peri_clks), clk_data);
-- 
2.25.1


_______________________________________________
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] 4+ messages in thread

* Re: [PATCH] clk: mediatek: clk-mt2701: Add check for mtk_alloc_clk_data
  2023-09-01  2:46 [PATCH] clk: mediatek: clk-mt2701: Add check for mtk_alloc_clk_data Jiasheng Jiang
@ 2023-09-04  9:48 ` Markus Schneider-Pargmann
  2023-09-07  9:06 ` AngeloGioacchino Del Regno
  2023-10-19  1:16 ` Stephen Boyd
  2 siblings, 0 replies; 4+ messages in thread
From: Markus Schneider-Pargmann @ 2023-09-04  9:48 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: mturquette, sboyd, matthias.bgg, angelogioacchino.delregno, wenst,
	frank.li, robh, jamesjj.liao, shunli.wang, erin.lo, linux-clk,
	linux-kernel, linux-arm-kernel, linux-mediatek

On Fri, Sep 01, 2023 at 10:46:58AM +0800, Jiasheng Jiang wrote:
> Add the check for the return value of mtk_alloc_clk_data() in order to
> avoid NULL pointer dereference.
> 
> Fixes: e9862118272a ("clk: mediatek: Add MT2701 clock support")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>

Reviewed-by: Markus Schneider-Pargmann <msp@baylibre.com>

Best,
Markus

> ---
>  drivers/clk/mediatek/clk-mt2701.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/clk/mediatek/clk-mt2701.c b/drivers/clk/mediatek/clk-mt2701.c
> index c81f3e33ce56..12d9560eb4ba 100644
> --- a/drivers/clk/mediatek/clk-mt2701.c
> +++ b/drivers/clk/mediatek/clk-mt2701.c
> @@ -667,6 +667,8 @@ static int mtk_topckgen_init(struct platform_device *pdev)
>  		return PTR_ERR(base);
>  
>  	clk_data = mtk_alloc_clk_data(CLK_TOP_NR);
> +	if (!clk_data)
> +		return -ENOMEM;
>  
>  	mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
>  								clk_data);
> @@ -747,6 +749,8 @@ static void __init mtk_infrasys_init_early(struct device_node *node)
>  
>  	if (!infra_clk_data) {
>  		infra_clk_data = mtk_alloc_clk_data(CLK_INFRA_NR);
> +		if (!infra_clk_data)
> +			return;
>  
>  		for (i = 0; i < CLK_INFRA_NR; i++)
>  			infra_clk_data->hws[i] = ERR_PTR(-EPROBE_DEFER);
> @@ -774,6 +778,8 @@ static int mtk_infrasys_init(struct platform_device *pdev)
>  
>  	if (!infra_clk_data) {
>  		infra_clk_data = mtk_alloc_clk_data(CLK_INFRA_NR);
> +		if (!infra_clk_data)
> +			return -ENOMEM;
>  	} else {
>  		for (i = 0; i < CLK_INFRA_NR; i++) {
>  			if (infra_clk_data->hws[i] == ERR_PTR(-EPROBE_DEFER))
> @@ -890,6 +896,8 @@ static int mtk_pericfg_init(struct platform_device *pdev)
>  		return PTR_ERR(base);
>  
>  	clk_data = mtk_alloc_clk_data(CLK_PERI_NR);
> +	if (!clk_data)
> +		return -ENOMEM;
>  
>  	mtk_clk_register_gates(&pdev->dev, node, peri_clks,
>  			       ARRAY_SIZE(peri_clks), clk_data);
> -- 
> 2.25.1
> 

_______________________________________________
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] 4+ messages in thread

* Re: [PATCH] clk: mediatek: clk-mt2701: Add check for mtk_alloc_clk_data
  2023-09-01  2:46 [PATCH] clk: mediatek: clk-mt2701: Add check for mtk_alloc_clk_data Jiasheng Jiang
  2023-09-04  9:48 ` Markus Schneider-Pargmann
@ 2023-09-07  9:06 ` AngeloGioacchino Del Regno
  2023-10-19  1:16 ` Stephen Boyd
  2 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-09-07  9:06 UTC (permalink / raw)
  To: Jiasheng Jiang, mturquette, sboyd, matthias.bgg, wenst, msp,
	frank.li, robh, jamesjj.liao, shunli.wang, erin.lo
  Cc: linux-clk, linux-kernel, linux-arm-kernel, linux-mediatek

Il 01/09/23 04:46, Jiasheng Jiang ha scritto:
> Add the check for the return value of mtk_alloc_clk_data() in order to
> avoid NULL pointer dereference.
> 
> Fixes: e9862118272a ("clk: mediatek: Add MT2701 clock support")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



_______________________________________________
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] 4+ messages in thread

* Re: [PATCH] clk: mediatek: clk-mt2701: Add check for mtk_alloc_clk_data
  2023-09-01  2:46 [PATCH] clk: mediatek: clk-mt2701: Add check for mtk_alloc_clk_data Jiasheng Jiang
  2023-09-04  9:48 ` Markus Schneider-Pargmann
  2023-09-07  9:06 ` AngeloGioacchino Del Regno
@ 2023-10-19  1:16 ` Stephen Boyd
  2 siblings, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2023-10-19  1:16 UTC (permalink / raw)
  To: Jiasheng Jiang, angelogioacchino.delregno, erin.lo, frank.li,
	jamesjj.liao, matthias.bgg, msp, mturquette, robh, shunli.wang,
	wenst
  Cc: linux-clk, linux-kernel, linux-arm-kernel, linux-mediatek,
	Jiasheng Jiang

Quoting Jiasheng Jiang (2023-08-31 19:46:58)
> Add the check for the return value of mtk_alloc_clk_data() in order to
> avoid NULL pointer dereference.
> 
> Fixes: e9862118272a ("clk: mediatek: Add MT2701 clock support")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---

Applied to clk-next

_______________________________________________
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] 4+ messages in thread

end of thread, other threads:[~2023-10-19  1:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-01  2:46 [PATCH] clk: mediatek: clk-mt2701: Add check for mtk_alloc_clk_data Jiasheng Jiang
2023-09-04  9:48 ` Markus Schneider-Pargmann
2023-09-07  9:06 ` AngeloGioacchino Del Regno
2023-10-19  1:16 ` Stephen Boyd

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