linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk/mediatek: fix missing null-check for mt7622
@ 2021-10-30 14:07 Chengfeng Ye
  2021-11-19 11:53 ` Matthias Brugger
  0 siblings, 1 reply; 2+ messages in thread
From: Chengfeng Ye @ 2021-10-30 14:07 UTC (permalink / raw)
  To: mturquette, sboyd, matthias.bgg
  Cc: linux-kernel, linux-mediatek, linux-clk, linux-arm-kernel, Chengfeng Ye

The return pointer of mtk_alloc_clk_data could
be null, adding null check for all the call sites.

Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk>
---
 drivers/clk/mediatek/clk-mt7622.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/clk/mediatek/clk-mt7622.c b/drivers/clk/mediatek/clk-mt7622.c
index ef5947e15c75..f16b3655ff76 100644
--- a/drivers/clk/mediatek/clk-mt7622.c
+++ b/drivers/clk/mediatek/clk-mt7622.c
@@ -620,6 +620,8 @@ static int mtk_topckgen_init(struct platform_device *pdev)
 		return PTR_ERR(base);
 
 	clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
+	if (!clk_data)
+		return -ENOMEM;
 
 	mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
 				    clk_data);
@@ -650,6 +652,8 @@ static int mtk_infrasys_init(struct platform_device *pdev)
 	int r;
 
 	clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK);
+	if (!clk_data)
+		return -ENOMEM;
 
 	mtk_clk_register_gates(node, infra_clks, ARRAY_SIZE(infra_clks),
 			       clk_data);
@@ -700,6 +704,8 @@ static int mtk_pericfg_init(struct platform_device *pdev)
 		return PTR_ERR(base);
 
 	clk_data = mtk_alloc_clk_data(CLK_PERI_NR_CLK);
+	if (!clk_data)
+		return -ENOMEM;
 
 	mtk_clk_register_gates(node, peri_clks, ARRAY_SIZE(peri_clks),
 			       clk_data);
-- 
2.17.1


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

* Re: [PATCH] clk/mediatek: fix missing null-check for mt7622
  2021-10-30 14:07 [PATCH] clk/mediatek: fix missing null-check for mt7622 Chengfeng Ye
@ 2021-11-19 11:53 ` Matthias Brugger
  0 siblings, 0 replies; 2+ messages in thread
From: Matthias Brugger @ 2021-11-19 11:53 UTC (permalink / raw)
  To: Chengfeng Ye, mturquette, sboyd
  Cc: linux-kernel, linux-mediatek, linux-clk, linux-arm-kernel



On 30/10/2021 16:07, Chengfeng Ye wrote:
> The return pointer of mtk_alloc_clk_data could
> be null, adding null check for all the call sites.
> 
> Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk>

This pattern is seen in nearly all MediaTek clock drivers. Is there any specific 
reason that you only fix the three?

Would you mind to check all of them and send the patches as a series instead of 
every patch one by one?

Regards,
Matthias

> ---
>   drivers/clk/mediatek/clk-mt7622.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/clk/mediatek/clk-mt7622.c b/drivers/clk/mediatek/clk-mt7622.c
> index ef5947e15c75..f16b3655ff76 100644
> --- a/drivers/clk/mediatek/clk-mt7622.c
> +++ b/drivers/clk/mediatek/clk-mt7622.c
> @@ -620,6 +620,8 @@ static int mtk_topckgen_init(struct platform_device *pdev)
>   		return PTR_ERR(base);
>   
>   	clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
> +	if (!clk_data)
> +		return -ENOMEM;
>   
>   	mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
>   				    clk_data);
> @@ -650,6 +652,8 @@ static int mtk_infrasys_init(struct platform_device *pdev)
>   	int r;
>   
>   	clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK);
> +	if (!clk_data)
> +		return -ENOMEM;
>   
>   	mtk_clk_register_gates(node, infra_clks, ARRAY_SIZE(infra_clks),
>   			       clk_data);
> @@ -700,6 +704,8 @@ static int mtk_pericfg_init(struct platform_device *pdev)
>   		return PTR_ERR(base);
>   
>   	clk_data = mtk_alloc_clk_data(CLK_PERI_NR_CLK);
> +	if (!clk_data)
> +		return -ENOMEM;
>   
>   	mtk_clk_register_gates(node, peri_clks, ARRAY_SIZE(peri_clks),
>   			       clk_data);
> 

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

end of thread, other threads:[~2021-11-19 11:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-30 14:07 [PATCH] clk/mediatek: fix missing null-check for mt7622 Chengfeng Ye
2021-11-19 11:53 ` Matthias Brugger

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