Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rudi Heitbaum" <rudi@heitbaum.com>
Cc: imx@lists.linux.dev, linux-pci@vger.kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH] PCI: imx6: Avoid dereferencing a NULL clock name
Date: Sun, 02 Aug 2026 11:14:43 +0000	[thread overview]
Message-ID: <20260802111444.952381F000E9@smtp.kernel.org> (raw)
In-Reply-To: <am8iBwJSEhYhWTqk@6cfee64030a6>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The patch successfully fixes a NULL pointer dereference in `imx_pcie_probe()` by checking `imx_pcie->clks[i].id` before passing it to `strncmp()`, but it misses an identical preexisting vulnerability in `imx_setup_phy_mpll()`.
--

--- Patch [1]: [PATCH] PCI: imx6: Avoid dereferencing a NULL clock name ---
commit 59f2384c27b018977b395ad505a6ac37e2ecf39a
Author: Rudi Heitbaum <rudi@heitbaum.com>

PCI: imx6: Avoid dereferencing a NULL clock name
    
This patch fixes a kernel oops in imx_pcie_probe() by checking if
clk_bulk_data::id is NULL before passing it to strncmp(). This happens
because of_clk_bulk_get() legally leaves the id as NULL for unnamed clocks.

> diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> index 98e1db751132a..9a9efc2ab894a 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -1826,7 +1826,8 @@ static int imx_pcie_probe(struct platform_device *pdev)
>  		return dev_err_probe(dev, imx_pcie->num_clks,
>  				     "failed to get clocks\n");
>  	for (i = 0; i < imx_pcie->num_clks; i++)
> -		if (strncmp(imx_pcie->clks[i].id, "extref", 6) == 0)
> +		if (imx_pcie->clks[i].id &&
> +		    strncmp(imx_pcie->clks[i].id, "extref", 6) == 0)
>  			imx_pcie->enable_ext_refclk = true;
>  
>  	if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_HAS_PHYDRV)) {

[Severity: High]
This is a pre-existing issue, but this same vulnerability appears to exist
elsewhere in this driver.

In imx_setup_phy_mpll(), the driver iterates over the clocks and calls
strncmp() on the id without checking if it is NULL:

drivers/pci/controller/dwc/pci-imx6.c:imx_setup_phy_mpll() {
    ...
	for (i = 0; i < imx_pcie->num_clks; i++)
		if (strncmp(clks[i].id, "pcie_phy", 8) == 0)
			phy_rate = clk_get_rate(clks[i].clk);
    ...
}

Could this cause a similar oops during probe when IMX_PCIE_FLAG_IMX_PHY is
used and an unnamed clock is present? Would it make sense to apply the same
NULL check to this loop?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/am8iBwJSEhYhWTqk@6cfee64030a6?part=1

  reply	other threads:[~2026-08-02 11:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-02 10:55 [PATCH] PCI: imx6: Avoid dereferencing a NULL clock name Rudi Heitbaum
2026-08-02 11:14 ` sashiko-bot [this message]
2026-08-03  2:54 ` Hongxing Zhu

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=20260802111444.952381F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=linux-pci@vger.kernel.org \
    --cc=rudi@heitbaum.com \
    --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