RE: [PATCH] PCI: imx6: Avoid dereferencing a NULL clock name

Hongxing Zhu <[email protected]> Mon, 3 Aug 2026 02:54:52 +0000
Newsgroups dev.linux.lists.imx,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci,org.kernel.vger.stable
Message-ID <GV2PR04MB120195449378280CCAF9503328CD52@GV2PR04MB12019.eurprd04.prod.outlook.com>
> -----Original Message-----
> From: Rudi Heitbaum <[email protected]>
> Sent: Sunday, August 2, 2026 6:55 PM
> To: Hongxing Zhu <[email protected]>; Lucas Stach
> <[email protected]>
> Cc: Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczy=F1ski
> <[email protected]>; Manivannan Sadhasivam <[email protected]>; Rob
> Herring <[email protected]>; Bjorn Helgaas <[email protected]>; linux-
> [email protected]; [email protected]; [email protected]=
x.dev;
> [email protected]; [email protected]; [email protected]
> Subject: [PATCH] PCI: imx6: Avoid dereferencing a NULL clock name
>=20
> [You don't often get email from [email protected]. Learn why this is impo=
rtant
> at https://aka.ms/LearnAboutSenderIdentification ]
>=20
> of_clk_bulk_get() leaves clk_bulk_data::id as NULL for every clock that h=
as no
> matching entry in "clock-names", which is legal: a node may list more "cl=
ocks"
> phandles than it names. The extref scan dereferences that id unconditiona=
lly, so
> such a node oopses during probe.
>=20
> Check clk_bulk_data::id before dereferencing it.
>=20
> Fixes: d8574ce57d76 ("PCI: imx6: Add external reference clock input mode
> support")
> Cc: [email protected]
> Signed-off-by: Rudi Heitbaum <[email protected]>
Good catch.
This isn't triggered in my daily tests, but the fix is correct.
Thanks for this fix.
Acked-by: Richard Zhu <[email protected]>

Best Regards
Richard Zhu
> ---
>  drivers/pci/controller/dwc/pci-imx6.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>=20
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c
> b/drivers/pci/controller/dwc/pci-imx6.c
> index f7389b5437df..dcdeba1856f7 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -1831,7 +1831,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 =3D 0; i < imx_pcie->num_clks; i++)
> -               if (strncmp(imx_pcie->clks[i].id, "extref", 6) =3D=3D 0)
> +               if (imx_pcie->clks[i].id &&
> +                   strncmp(imx_pcie->clks[i].id, "extref", 6) =3D=3D 0)
>                         imx_pcie->enable_ext_refclk =3D true;
>=20
>         if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_HAS_PHYDRV)) {
> --
> 2.53.0