Re: [PATCH] PCI: j721e: Properly check the error of a syscon lookup

From: Bjorn Helgaas

Date: Mon Nov 30 2026 - 14:59:17 EST


[+cc Simon, Ye for possible similar problems in pinctrl-rockchip.c]

On Fri, Nov 27, 2026 at 10:19:13AM +0000, Anton Protopopov wrote:
> The syscon_regmap_lookup_by_phandle_optional() function returns NULL
> only when the property is missing (-ENODEV). On other errors it returns
> an error pointer. The j721e_pcie_ctrl_init() function checks only for
> NULL and passes an error pointer to j721e_enable_acspcie_refclk(),
> which uses it as a regmap. Propagate the error instead.

"Properly" in the subject is a noise word that takes up space without
adding much value.

IIUC this avoids issues like a kernel oops when using an error pointer
(-EINVAL, etc) as a regmap pointer.

There are only five callers of syscon_regmap_lookup_by_phandle_optional()
in the tree. wpcm_fiu_probe() looks right, and you're fixing this one.

The other three are in drivers/pinctrl/pinctrl-rockchip.c, which looks
kind of suspicious, or at least too complicated to verify at a glance.
These were added by:

63113d4fce6c ("pinctrl: rockchip: Add RV1106 pinctrl support")
dbd2317d7b9f ("pinctrl: rockchip: Add rk3506 pinctrl support")

> Fixes: 82c4be4168e2 ("PCI: j721e: Enable ACSPCIE Refclk if "ti,syscon-acspcie-proxy-ctrl" exists")
> Signed-off-by: Anton Protopopov <a.s.protopopov@xxxxxxxxx>
> ---
>
> (Accidentally bumped into this while working on BPF stuff.)
>
> drivers/pci/controller/cadence/pci-j721e.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c
> index 822602836b12..fdae51e368e0 100644
> --- a/drivers/pci/controller/cadence/pci-j721e.c
> +++ b/drivers/pci/controller/cadence/pci-j721e.c
> @@ -334,6 +334,8 @@ static int j721e_pcie_ctrl_init(struct j721e_pcie *pcie)
> "ti,syscon-acspcie-proxy-ctrl");
> if (!syscon)
> return 0;
> + if (IS_ERR(syscon))
> + return PTR_ERR(syscon);
>
> return j721e_enable_acspcie_refclk(pcie, syscon);
> }