mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] PCI: sky1: Fix missing cleanup of ECAM config on probe failure
@ 2026-03-23 16:41 Felix Gu
  2026-03-24  5:43 ` Hans Zhang
  2026-03-24  7:21 ` Manivannan Sadhasivam
  0 siblings, 2 replies; 4+ messages in thread
From: Felix Gu @ 2026-03-23 16:41 UTC (permalink / raw)
  To: Hans Zhang, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas
  Cc: linux-pci, linux-kernel, Felix Gu

When devm_kzalloc() for reg_off fails, the code returns -ENOMEM
without freeing pcie->cfg, which was allocated earlier by
pci_ecam_create().

Add the missing pci_ecam_free() call to properly release the allocated
ECAM configuration window on this error path.

Fixes: a0d9f2c08f45 ("PCI: sky1: Add PCIe host support for CIX Sky1")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
 drivers/pci/controller/cadence/pci-sky1.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/cadence/pci-sky1.c b/drivers/pci/controller/cadence/pci-sky1.c
index d8c216dc120d..9853a9c82c0e 100644
--- a/drivers/pci/controller/cadence/pci-sky1.c
+++ b/drivers/pci/controller/cadence/pci-sky1.c
@@ -176,8 +176,10 @@ static int sky1_pcie_probe(struct platform_device *pdev)
 	cdns_pcie->is_rc = 1;
 
 	reg_off = devm_kzalloc(dev, sizeof(*reg_off), GFP_KERNEL);
-	if (!reg_off)
+	if (!reg_off) {
+		pci_ecam_free(pcie->cfg);
 		return -ENOMEM;
+	}
 
 	reg_off->ip_reg_bank_offset = SKY1_IP_REG_BANK;
 	reg_off->ip_cfg_ctrl_reg_offset = SKY1_IP_CFG_CTRL_REG_BANK;

---
base-commit: 785f0eb2f85decbe7c1ef9ae922931f0194ffc2e
change-id: 20260323-sky1-890a90a72bc6

Best regards,
-- 
Felix Gu <ustc.gu@gmail.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] PCI: sky1: Fix missing cleanup of ECAM config on probe failure
  2026-03-23 16:41 [PATCH] PCI: sky1: Fix missing cleanup of ECAM config on probe failure Felix Gu
@ 2026-03-24  5:43 ` Hans Zhang
  2026-03-24  7:21 ` Manivannan Sadhasivam
  1 sibling, 0 replies; 4+ messages in thread
From: Hans Zhang @ 2026-03-24  5:43 UTC (permalink / raw)
  To: Felix Gu, Hans Zhang, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
	Bjorn Helgaas
  Cc: linux-pci, linux-kernel



On 3/24/26 00:41, Felix Gu wrote:
> When devm_kzalloc() for reg_off fails, the code returns -ENOMEM
> without freeing pcie->cfg, which was allocated earlier by
> pci_ecam_create().
> 
> Add the missing pci_ecam_free() call to properly release the allocated
> ECAM configuration window on this error path.
> 
> Fixes: a0d9f2c08f45 ("PCI: sky1: Add PCIe host support for CIX Sky1")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>

Reviewed-by: Hans Zhang <18255117159@163.com>

> ---
>   drivers/pci/controller/cadence/pci-sky1.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/cadence/pci-sky1.c b/drivers/pci/controller/cadence/pci-sky1.c
> index d8c216dc120d..9853a9c82c0e 100644
> --- a/drivers/pci/controller/cadence/pci-sky1.c
> +++ b/drivers/pci/controller/cadence/pci-sky1.c
> @@ -176,8 +176,10 @@ static int sky1_pcie_probe(struct platform_device *pdev)
>   	cdns_pcie->is_rc = 1;
>   
>   	reg_off = devm_kzalloc(dev, sizeof(*reg_off), GFP_KERNEL);
> -	if (!reg_off)
> +	if (!reg_off) {
> +		pci_ecam_free(pcie->cfg);
>   		return -ENOMEM;
> +	}
>   
>   	reg_off->ip_reg_bank_offset = SKY1_IP_REG_BANK;
>   	reg_off->ip_cfg_ctrl_reg_offset = SKY1_IP_CFG_CTRL_REG_BANK;
> 
> ---
> base-commit: 785f0eb2f85decbe7c1ef9ae922931f0194ffc2e
> change-id: 20260323-sky1-890a90a72bc6
> 
> Best regards,


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] PCI: sky1: Fix missing cleanup of ECAM config on probe failure
  2026-03-23 16:41 [PATCH] PCI: sky1: Fix missing cleanup of ECAM config on probe failure Felix Gu
  2026-03-24  5:43 ` Hans Zhang
@ 2026-03-24  7:21 ` Manivannan Sadhasivam
  2026-03-24 18:54   ` Markus Elfring
  1 sibling, 1 reply; 4+ messages in thread
From: Manivannan Sadhasivam @ 2026-03-24  7:21 UTC (permalink / raw)
  To: Hans Zhang, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Rob Herring, Bjorn Helgaas, Felix Gu
  Cc: linux-pci, linux-kernel


On Tue, 24 Mar 2026 00:41:28 +0800, Felix Gu wrote:
> When devm_kzalloc() for reg_off fails, the code returns -ENOMEM
> without freeing pcie->cfg, which was allocated earlier by
> pci_ecam_create().
> 
> Add the missing pci_ecam_free() call to properly release the allocated
> ECAM configuration window on this error path.
> 
> [...]

Applied, thanks!

[1/1] PCI: sky1: Fix missing cleanup of ECAM config on probe failure
      commit: 72e76b63d6ff6d1f96acccbfc6c118656f63e66a

Best regards,
-- 
Manivannan Sadhasivam <mani@kernel.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] PCI: sky1: Fix missing cleanup of ECAM config on probe failure
  2026-03-24  7:21 ` Manivannan Sadhasivam
@ 2026-03-24 18:54   ` Markus Elfring
  0 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2026-03-24 18:54 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Felix Gu, linux-pci, Bjorn Helgaas,
	Hans Zhang, Krzysztof Wilczyński, Lorenzo Pieralisi,
	Rob Herring
  Cc: Manivannan Sadhasivam, LKML, kernel-janitors, Hans Zhang

> > Add the missing pci_ecam_free() call to properly release the allocated
> > ECAM configuration window on this error path.
…
> Applied, thanks!
> 
> [1/1] PCI: sky1: Fix missing cleanup of ECAM config on probe failure
>       commit: 72e76b63d6ff6d1f96acccbfc6c118656f63e66a

Can the application of another goto chain become more desirable for
the implementation of the function “sky1_pcie_probe”?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v7.0-rc5#n526

Regards,
Markus

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-24 18:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-23 16:41 [PATCH] PCI: sky1: Fix missing cleanup of ECAM config on probe failure Felix Gu
2026-03-24  5:43 ` Hans Zhang
2026-03-24  7:21 ` Manivannan Sadhasivam
2026-03-24 18:54   ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®