lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <e700cea3-cbe7-4ab5-94d8-a211051e2472@collabora.com>
Date: Mon, 22 Sep 2025 12:55:14 +0200
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
To: Alok Tiwari <alok.a.tiwari@...cle.com>, thomas.petazzoni@...tlin.com,
 pali@...nel.org, lpieralisi@...nel.org, kwilczynski@...nel.org,
 mani@...nel.org, robh@...nel.org, bhelgaas@...gle.com, joyce.ooi@...el.com,
 alyssa@...enzweig.io, maz@...nel.org, jim2101024@...il.com,
 florian.fainelli@...adcom.com, bcm-kernel-feedback-list@...adcom.com,
 rjui@...adcom.com, sbranden@...adcom.com, ryder.lee@...iatek.com,
 jianjun.wang@...iatek.com, sergio.paracuellos@...il.com,
 matthias.bgg@...il.com, marek.vasut+renesas@...il.com,
 yoshihiro.shimoda.uh@...esas.com, geert+renesas@...der.be,
 magnus.damm@...il.com, shawn.lin@...k-chips.com, heiko@...ech.de,
 michal.simek@....com, bharat.kumar.gogada@....com, will@...nel.org,
 kys@...rosoft.com, haiyangz@...rosoft.com, wei.liu@...nel.org,
 decui@...rosoft.com, linus.walleij@...aro.org, thierry.reding@...il.com,
 jonathanh@...dia.com, rric@...nel.org, nirmal.patel@...ux.intel.com,
 toan@...amperecomputing.com, jonathan.derrick@...ux.dev,
 linux-pci@...r.kernel.org
Cc: linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
 linux-rpi-kernel@...ts.infradead.org, linux-mediatek@...ts.infradead.org,
 linux-renesas-soc@...r.kernel.org, linux-rockchip@...ts.infradead.org,
 linux-hyperv@...r.kernel.org, linux-tegra@...r.kernel.org
Subject: Re: [PATCH RFC] PCI: Convert devm_pci_alloc_host_bridge() users to
 error-pointer returns

Il 21/09/25 18:14, Alok Tiwari ha scritto:
> devm_pci_alloc_host_bridge() and pci_alloc_host_bridge() previously
> returned NULL on failure, forcing callers to special-case NULL handling
> and often hardcode -ENOMEM as the error.
> 
> This series updates devm_pci_alloc_host_bridge() to consistently return
> error pointers (ERR_PTR) with the actual error code, instead of NULL.
> All callers across PCI host controller drivers are updated to use
> IS_ERR_OR_NULL()/PTR_ERR() instead of NULL checks and hardcoded -ENOMEM.
> 
> Benefits:
>    - Standardizes error handling with Linux kernel ERR_PTR()/PTR_ERR()
>      conventions.
>    - Ensures that the actual error code from lower-level helpers is
>      propagated back to the caller.
>    - Removes ambiguity between NULL and error pointer returns.
> 
> Touched drivers include:
>   cadence (J721E, cadence-plat)
>   dwc (designware, qcom)
>   mobiveil (layerscape-gen4, mobiveil-plat)
>   aardvark, ftpci100, ixp4xx, loongson, mvebu, rcar, tegra, v3-semi,
>   versatile, xgene, altera, brcmstb, iproc, mediatek, mt7621, xilinx,
>   plda, and others
> 
> This patch updates error handling across these host controller drivers
>   so that callers consistently receive ERR_PTR() instead of NULL.
> 

I think that's a nice improvement - propagating the right error code looks good.

The only thing is - you have to make sure that it never returns NULL, so that
in the controller drivers you always check for `if (IS_ERR(x))` - otherwise with
the current IS_ERR_OR_NULL(x) most of the error paths are wrong.

Cheers,
Angelo

> Signed-off-by: Alok Tiwari <alok.a.tiwari@...cle.com>
> ---
>   arch/mips/pci/pci-xtalk-bridge.c                       | 4 ++--
>   drivers/pci/controller/cadence/pci-j721e.c             | 4 ++--
>   drivers/pci/controller/cadence/pcie-cadence-plat.c     | 4 ++--
>   drivers/pci/controller/dwc/pcie-designware-host.c      | 4 ++--
>   drivers/pci/controller/dwc/pcie-qcom.c                 | 4 ++--
>   drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c | 4 ++--
>   drivers/pci/controller/mobiveil/pcie-mobiveil-plat.c   | 4 ++--
>   drivers/pci/controller/pci-aardvark.c                  | 4 ++--
>   drivers/pci/controller/pci-ftpci100.c                  | 4 ++--
>   drivers/pci/controller/pci-host-common.c               | 4 ++--
>   drivers/pci/controller/pci-hyperv.c                    | 4 ++--
>   drivers/pci/controller/pci-ixp4xx.c                    | 4 ++--
>   drivers/pci/controller/pci-loongson.c                  | 4 ++--
>   drivers/pci/controller/pci-mvebu.c                     | 4 ++--
>   drivers/pci/controller/pci-rcar-gen2.c                 | 4 ++--
>   drivers/pci/controller/pci-tegra.c                     | 4 ++--
>   drivers/pci/controller/pci-v3-semi.c                   | 4 ++--
>   drivers/pci/controller/pci-versatile.c                 | 4 ++--
>   drivers/pci/controller/pci-xgene.c                     | 4 ++--
>   drivers/pci/controller/pcie-altera.c                   | 4 ++--
>   drivers/pci/controller/pcie-brcmstb.c                  | 4 ++--
>   drivers/pci/controller/pcie-iproc-bcma.c               | 4 ++--
>   drivers/pci/controller/pcie-iproc-platform.c           | 4 ++--
>   drivers/pci/controller/pcie-mediatek-gen3.c            | 4 ++--
>   drivers/pci/controller/pcie-mediatek.c                 | 4 ++--
>   drivers/pci/controller/pcie-mt7621.c                   | 4 ++--
>   drivers/pci/controller/pcie-rcar-host.c                | 4 ++--
>   drivers/pci/controller/pcie-rockchip-host.c            | 4 ++--
>   drivers/pci/controller/pcie-xilinx-cpm.c               | 4 ++--
>   drivers/pci/controller/pcie-xilinx-dma-pl.c            | 4 ++--
>   drivers/pci/controller/pcie-xilinx-nwl.c               | 4 ++--
>   drivers/pci/controller/pcie-xilinx.c                   | 4 ++--
>   drivers/pci/controller/plda/pcie-plda-host.c           | 4 ++--
>   drivers/pci/probe.c                                    | 8 ++++----
>   34 files changed, 70 insertions(+), 70 deletions(-)
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ