* [PATCH] usb: cdns3: Fix double resource release in cdns3_pci_probe
@ 2025-10-26 9:08 Miaoqian Lin
2025-10-27 3:24 ` Peter Chen (CIX)
0 siblings, 1 reply; 2+ messages in thread
From: Miaoqian Lin @ 2025-10-26 9:08 UTC (permalink / raw)
To: Peter Chen, Pawel Laszczak, Roger Quadros, Greg Kroah-Hartman,
Felipe Balbi, linux-usb, linux-kernel
Cc: linmq006, stable
The driver uses pcim_enable_device() to enable the PCI device,
the device will be automatically disabled on driver detach through
the managed device framework. The manual pci_disable_device() calls
in the error paths are therefore redundant and should be removed.
Found via static anlaysis and this is similar to commit 99ca0b57e49f
("thermal: intel: int340x: processor: Fix warning during module unload").
Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
Cc: stable@vger.kernel.org
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
drivers/usb/cdns3/cdns3-pci-wrap.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/usb/cdns3/cdns3-pci-wrap.c b/drivers/usb/cdns3/cdns3-pci-wrap.c
index 3b3b3dc75f35..57f57c24c663 100644
--- a/drivers/usb/cdns3/cdns3-pci-wrap.c
+++ b/drivers/usb/cdns3/cdns3-pci-wrap.c
@@ -98,10 +98,8 @@ static int cdns3_pci_probe(struct pci_dev *pdev,
wrap = pci_get_drvdata(func);
} else {
wrap = kzalloc(sizeof(*wrap), GFP_KERNEL);
- if (!wrap) {
- pci_disable_device(pdev);
+ if (!wrap)
return -ENOMEM;
- }
}
res = wrap->dev_res;
@@ -160,7 +158,6 @@ static int cdns3_pci_probe(struct pci_dev *pdev,
/* register platform device */
wrap->plat_dev = platform_device_register_full(&plat_info);
if (IS_ERR(wrap->plat_dev)) {
- pci_disable_device(pdev);
err = PTR_ERR(wrap->plat_dev);
kfree(wrap);
return err;
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: cdns3: Fix double resource release in cdns3_pci_probe
2025-10-26 9:08 [PATCH] usb: cdns3: Fix double resource release in cdns3_pci_probe Miaoqian Lin
@ 2025-10-27 3:24 ` Peter Chen (CIX)
0 siblings, 0 replies; 2+ messages in thread
From: Peter Chen (CIX) @ 2025-10-27 3:24 UTC (permalink / raw)
To: Miaoqian Lin
Cc: Pawel Laszczak, Roger Quadros, Greg Kroah-Hartman, Felipe Balbi,
linux-usb, linux-kernel, stable
On 25-10-26 17:08:59, Miaoqian Lin wrote:
> The driver uses pcim_enable_device() to enable the PCI device,
> the device will be automatically disabled on driver detach through
> the managed device framework. The manual pci_disable_device() calls
> in the error paths are therefore redundant and should be removed.
>
> Found via static anlaysis and this is similar to commit 99ca0b57e49f
> ("thermal: intel: int340x: processor: Fix warning during module unload").
>
> Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Acked-by: Peter Chen <peter.chen@kernel.org>
Peter
> ---
> drivers/usb/cdns3/cdns3-pci-wrap.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/usb/cdns3/cdns3-pci-wrap.c b/drivers/usb/cdns3/cdns3-pci-wrap.c
> index 3b3b3dc75f35..57f57c24c663 100644
> --- a/drivers/usb/cdns3/cdns3-pci-wrap.c
> +++ b/drivers/usb/cdns3/cdns3-pci-wrap.c
> @@ -98,10 +98,8 @@ static int cdns3_pci_probe(struct pci_dev *pdev,
> wrap = pci_get_drvdata(func);
> } else {
> wrap = kzalloc(sizeof(*wrap), GFP_KERNEL);
> - if (!wrap) {
> - pci_disable_device(pdev);
> + if (!wrap)
> return -ENOMEM;
> - }
> }
>
> res = wrap->dev_res;
> @@ -160,7 +158,6 @@ static int cdns3_pci_probe(struct pci_dev *pdev,
> /* register platform device */
> wrap->plat_dev = platform_device_register_full(&plat_info);
> if (IS_ERR(wrap->plat_dev)) {
> - pci_disable_device(pdev);
> err = PTR_ERR(wrap->plat_dev);
> kfree(wrap);
> return err;
> --
> 2.39.5 (Apple Git-154)
>
--
Best regards,
Peter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-27 3:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-26 9:08 [PATCH] usb: cdns3: Fix double resource release in cdns3_pci_probe Miaoqian Lin
2025-10-27 3:24 ` Peter Chen (CIX)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).