Linux clock framework development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Christian Marangi" <ansuelsmth@gmail.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org,
	linux-clk@vger.kernel.org
Subject: Re: [PATCH v7 3/3] clk: en7523: add support for Airoha AN7583 clock
Date: Fri, 09 Oct 2026 07:15:20 +0000	[thread overview]
Message-ID: <sashiko-outbox-164987@kernel.org> (raw)
In-Reply-To: <20261009070725.13196-4-ansuelsmth@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] clk: en7523: NULL pointer dereference in PHY ops due to missing priv->base initialization
--

commit 37bd1589683423a3a7795bb6de626bc15702ea39
Author: Christian Marangi <ansuelsmth@gmail.com>

clk: en7523: add support for Airoha AN7583 clock
    
Add support for Airoha AN7583 clock and reset.
    
Airoha AN7583 SoC have the same register address of EN7581 but implement
different bits and additional base clocks. Also reset are different with
the introduction of 2 dedicated MDIO line and drop of some reset lines.

> diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c
> index ec66a504d4c55..d3a273b46c8f0 100644
> --- a/drivers/clk/clk-en7523.c
> +++ b/drivers/clk/clk-en7523.c

[ ... ]

> @@ -1088,6 +1287,40 @@ static int en7581_clk_hw_init(struct platform_device *pdev,
>  	return en7581_serdes_phy_register(&pdev->dev);
>  }
>  
> +static int an7583_clk_hw_init(struct platform_device *pdev,
> +			      struct clk_hw_onecell_data *clk_data)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct regmap *map;
> +	void __iomem *base;
> +	u32 val;
> +	int ret;
> +
> +	map = syscon_regmap_lookup_by_phandle(dev->of_node, "airoha,chip-scu");
> +	if (IS_ERR(map))
> +		return PTR_ERR(map);
> +
> +	base = devm_platform_ioremap_resource(pdev, 0);
> +	if (IS_ERR(base))
> +		return PTR_ERR(base);
> +
> +	en7581_register_clocks(dev, clk_data, map, base);

[Severity: High]
Are we missing a step to retrieve the driver data and assign priv->base = base
here, similar to what is done in en7581_clk_hw_init()?

Without this initialization, when the PHY is later configured,
en7581_serdes_phy_set_mode() will attempt to access the mapped resource:

drivers/clk/clk-en7523.c:en7581_serdes_phy_set_mode() {
    ...
	spin_lock_irqsave(&priv->lock, flags);
	val = readl(priv->base + reg);
	val &= ~mask;
    ...
}

Because priv was zero-allocated during probe, priv->base will be NULL here,
which could lead to a NULL pointer dereference when readl is called.

> +
> +	val = readl(base + REG_RST_CTRL1);
> +	val |= REG_PCIE_HB_RST;
> +	writel(val, base + REG_RST_CTRL1);
> +	val &= ~REG_PCIE_HB_RST;
> +	writel(val, base + REG_RST_CTRL1);
> +
> +	ret = en7581_reset_register(dev, base, an7583_rst_map,
> +				    ARRAY_SIZE(an7583_rst_map),
> +				    en7581_rst_ofs);
> +	if (ret)
> +		return ret;
> +
> +	return en7581_serdes_phy_register(dev);
> +}
> +

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261009070725.13196-1-ansuelsmth@gmail.com?part=3

      reply	other threads:[~2026-10-09  7:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09  7:07 [PATCH v7 0/3] clk: add support for Airoha AN7583 clock Christian Marangi
2026-10-09  7:07 ` [PATCH v7 1/3] dt-bindings: clock: airoha: Document support for " Christian Marangi
2026-10-09  7:14   ` sashiko-bot
2026-10-09 15:12   ` Conor Dooley
2026-10-09 17:23     ` Christian Marangi (Ansuel)
2026-10-09 18:46       ` Conor Dooley
2026-10-09  7:07 ` [PATCH v7 2/3] clk: en7523: generalize register clocks function Christian Marangi
2026-10-09  7:07 ` [PATCH v7 3/3] clk: en7523: add support for Airoha AN7583 clock Christian Marangi
2026-10-09  7:15   ` sashiko-bot [this message]

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=sashiko-outbox-164987@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ansuelsmth@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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