linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Markus Schneider-Pargmann <msp@baylibre.com>
To: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Cc: mturquette@baylibre.com, sboyd@kernel.org,
	matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com,
	wenst@chromium.org, frank.li@vivo.com, robh@kernel.org,
	jamesjj.liao@mediatek.com, shunli.wang@mediatek.com,
	erin.lo@mediatek.com, linux-clk@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH] clk: mediatek: clk-mt2701: Add check for mtk_alloc_clk_data
Date: Mon, 4 Sep 2023 11:48:02 +0200	[thread overview]
Message-ID: <20230904094802.6fasingt4m4yked3@blmsp> (raw)
In-Reply-To: <20230901024658.23405-1-jiasheng@iscas.ac.cn>

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

  reply	other threads:[~2023-09-04  9:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-09-07  9:06 ` AngeloGioacchino Del Regno
2023-10-19  1:16 ` Stephen Boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230904094802.6fasingt4m4yked3@blmsp \
    --to=msp@baylibre.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=erin.lo@mediatek.com \
    --cc=frank.li@vivo.com \
    --cc=jamesjj.liao@mediatek.com \
    --cc=jiasheng@iscas.ac.cn \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=mturquette@baylibre.com \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=shunli.wang@mediatek.com \
    --cc=wenst@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).