mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] net/qla3xxx: Use managed PCI device enablement
@ 2026-09-11  3:32 Myeonghun Pak
  2026-09-13 14:46 ` Simon Horman
  0 siblings, 1 reply; 3+ messages in thread
From: Myeonghun Pak @ 2026-09-11  3:32 UTC (permalink / raw)
  To: GR-Linux-NIC-Dev
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, Ijae Kim

ql3xxx_probe() enables the PCI device and balances that reference on
probe failure. However, ql3xxx_remove() releases the mappings and PCI
regions without disabling the device, leaving the enable reference
held after unbind.

Use pcim_enable_device() so the PCI device is disabled automatically on
probe failure and driver detach. Remove the explicit disable from the
probe error path to avoid disabling the managed device twice.

Keep the existing manual cleanup of register mappings, PCI regions and
the netdev. These resources are released before the managed PCI disable
action runs.

This issue was identified during our ongoing static-analysis research while
reviewing kernel code.

Fixes: 5a4faa873782 ("[PATCH] qla3xxx NIC driver")
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
 drivers/net/ethernet/qlogic/qla3xxx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c
index 861a13ad7e1ac50fd1607818d592828c869dba0e..c1fe943c91319956c62e317e99478b936562663f 100644
--- a/drivers/net/ethernet/qlogic/qla3xxx.c
+++ b/drivers/net/ethernet/qlogic/qla3xxx.c
@@ -3755,7 +3755,7 @@ static int ql3xxx_probe(struct pci_dev *pdev,
 	static int cards_found;
 	int err;
 
-	err = pci_enable_device(pdev);
+	err = pcim_enable_device(pdev);
 	if (err) {
 		pr_err("%s cannot enable PCI device\n", pci_name(pdev));
 		goto err_out;
@@ -3764,7 +3764,7 @@ static int ql3xxx_probe(struct pci_dev *pdev,
 	err = pci_request_regions(pdev, DRV_NAME);
 	if (err) {
 		pr_err("%s cannot obtain PCI resources\n", pci_name(pdev));
-		goto err_out_disable_pdev;
+		goto err_out;
 	}
 
 	pci_set_master(pdev);
@@ -3891,8 +3891,6 @@ static int ql3xxx_probe(struct pci_dev *pdev,
 	free_netdev(ndev);
 err_out_free_regions:
 	pci_release_regions(pdev);
-err_out_disable_pdev:
-	pci_disable_device(pdev);
 err_out:
 	return err;
 }
-- 
2.53.0

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

* Re: [PATCH net] net/qla3xxx: Use managed PCI device enablement
  2026-09-11  3:32 [PATCH net] net/qla3xxx: Use managed PCI device enablement Myeonghun Pak
@ 2026-09-13 14:46 ` Simon Horman
  2026-09-13 20:39   ` Myeonghun Pak
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Horman @ 2026-09-13 14:46 UTC (permalink / raw)
  To: Myeonghun Pak
  Cc: GR-Linux-NIC-Dev, andrew+netdev, davem, edumazet, kuba, pabeni,
	netdev, linux-kernel, Ijae Kim

On Thu, Sep 10, 2026 at 11:32:19PM -0400, Myeonghun Pak wrote:
> ql3xxx_probe() enables the PCI device and balances that reference on
> probe failure. However, ql3xxx_remove() releases the mappings and PCI
> regions without disabling the device, leaving the enable reference
> held after unbind.
> 
> Use pcim_enable_device() so the PCI device is disabled automatically on
> probe failure and driver detach. Remove the explicit disable from the
> probe error path to avoid disabling the managed device twice.
> 
> Keep the existing manual cleanup of register mappings, PCI regions and
> the netdev. These resources are released before the managed PCI disable
> action runs.
> 
> This issue was identified during our ongoing static-analysis research while
> reviewing kernel code.
> 
> Fixes: 5a4faa873782 ("[PATCH] qla3xxx NIC driver")
> Co-developed-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>

I think that rather than introducing the use of managed resource APIs
to this driver, which is not encouraged in Networking code [1],
the preferred approach would be to add a pci_disable_device() call
to ql3xxx_remove().

[1] https://docs.kernel.org/process/maintainer-netdev.html#using-device-managed-and-cleanup-h-constructs

   "Using device-managed and cleanup.h constructs

   "Netdev remains skeptical about promises of all “auto-cleanup” APIs,
    including even devm_ helpers, historically. They are not the preferred
    style of implementation, merely an acceptable one.

-- 
pw-bot: changes-requested

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

* Re: [PATCH net] net/qla3xxx: Use managed PCI device enablement
  2026-09-13 14:46 ` Simon Horman
@ 2026-09-13 20:39   ` Myeonghun Pak
  0 siblings, 0 replies; 3+ messages in thread
From: Myeonghun Pak @ 2026-09-13 20:39 UTC (permalink / raw)
  To: Simon Horman
  Cc: GR-Linux-NIC-Dev, andrew+netdev, davem, edumazet, kuba, pabeni,
	netdev, linux-kernel, Ijae Kim

Thanks for the review. I'll keep the existing manual resource
management and add pci_disable_device() to ql3xxx_remove() in v2.

2026년 9월 13일 (일) 오전 10:46, Simon Horman <horms@kernel.org>님이 작성:
>
> On Thu, Sep 10, 2026 at 11:32:19PM -0400, Myeonghun Pak wrote:
> > ql3xxx_probe() enables the PCI device and balances that reference on
> > probe failure. However, ql3xxx_remove() releases the mappings and PCI
> > regions without disabling the device, leaving the enable reference
> > held after unbind.
> >
> > Use pcim_enable_device() so the PCI device is disabled automatically on
> > probe failure and driver detach. Remove the explicit disable from the
> > probe error path to avoid disabling the managed device twice.
> >
> > Keep the existing manual cleanup of register mappings, PCI regions and
> > the netdev. These resources are released before the managed PCI disable
> > action runs.
> >
> > This issue was identified during our ongoing static-analysis research while
> > reviewing kernel code.
> >
> > Fixes: 5a4faa873782 ("[PATCH] qla3xxx NIC driver")
> > Co-developed-by: Ijae Kim <ae878000@gmail.com>
> > Signed-off-by: Ijae Kim <ae878000@gmail.com>
> > Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
>
> I think that rather than introducing the use of managed resource APIs
> to this driver, which is not encouraged in Networking code [1],
> the preferred approach would be to add a pci_disable_device() call
> to ql3xxx_remove().
>
> [1] https://docs.kernel.org/process/maintainer-netdev.html#using-device-managed-and-cleanup-h-constructs
>
>    "Using device-managed and cleanup.h constructs
>
>    "Netdev remains skeptical about promises of all “auto-cleanup” APIs,
>     including even devm_ helpers, historically. They are not the preferred
>     style of implementation, merely an acceptable one.
>
> --
> pw-bot: changes-requested

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

end of thread, other threads:[~2026-09-13 20:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11  3:32 [PATCH net] net/qla3xxx: Use managed PCI device enablement Myeonghun Pak
2026-09-13 14:46 ` Simon Horman
2026-09-13 20:39   ` Myeonghun Pak

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®