From: Yige Jiang <yigejiang86@gmail.com>
To: linux-pci@vger.kernel.org
Cc: Yige Jiang <yigejiang86@gmail.com>,
Kurt Schwemmer <kurt.schwemmer@microsemi.com>,
Logan Gunthorpe <logang@deltatee.com>,
Bjorn Helgaas <bhelgaas@google.com>,
linux-kernel@vger.kernel.org, Daniel Stodden <dns@arista.com>
Subject: [PATCH] PCI: switchtec: Fix PCI device reference leak on probe failure
Date: Thu, 5 Nov 2026 15:55:01 +0800 [thread overview]
Message-ID: <rc-review-20261105-vc-149-07fa7f0c8a18@gmail.com> (raw)
stdev_create() takes a pci_dev reference for stdev->pdev. When a
later step of switchtec_pci_probe() fails, err_put drops stdev->dev
but omits the PCI device reference. stdev_release() only frees
stdev, so the PCI device remains pinned after the failed probe.
Return the PCI device reference before putting stdev->dev, matching
the existing cleanup in stdev_create() and switchtec_pci_remove().
Fixes: df25461119d9 ("PCI: switchtec: Fix stdev_release() crash after surprise hot remove")
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Based on linux-next next-20261102 (2637bdec0535).
Compile-tested: arm64, GCC 14.2.0, W=1, CONFIG_OF_DYNAMIC=y.
COMPILE_TEST=y.
Baseline and patched target objects built from this exact base.
No full kernel/module-link, hardware or runtime test was performed.
AI assistance was used for analysis and patch preparation.
drivers/pci/switch/switchtec.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
index 5711aaa5df11..56a370ac9f27 100644
--- a/drivers/pci/switch/switchtec.c
+++ b/drivers/pci/switch/switchtec.c
@@ -1698,6 +1698,7 @@ err_exit_pci:
switchtec_exit_pci(stdev);
err_put:
ida_free(&switchtec_minor_ida, MINOR(stdev->dev.devt));
+ pci_dev_put(stdev->pdev);
put_device(&stdev->dev);
return rc;
}
base-commit: 2637bdec0535a2044cd830eba9a79363651d9043
reply other threads:[~2026-11-05 7:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=rc-review-20261105-vc-149-07fa7f0c8a18@gmail.com \
--to=yigejiang86@gmail.com \
--cc=bhelgaas@google.com \
--cc=dns@arista.com \
--cc=kurt.schwemmer@microsemi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=logang@deltatee.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®