From: Wentao Liang <vulab@iscas.ac.cn>
To: djbw@kernel.org, bhelgaas@google.com
Cc: linux-coco@lists.linux.dev, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org, Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] PCI/TSM: fix use-after-free in find_dsm_dev()
Date: Tue, 16 Jun 2026 03:02:43 +0000 [thread overview]
Message-ID: <20260616030243.1661791-1-vulab@iscas.ac.cn> (raw)
In find_dsm_dev(), pf0 is obtained via pf0_dev_get() which returns a
reference-counted pointer. It is declared with __free(pci_dev_put),
so pci_dev_put() will be called when the variable goes out of scope.
Returning 'pf0' directly while it still has __free cleanup causes the
reference to be dropped before the caller can use the pointer, leading
to a use-after-free.
Fix by using return no_free_ptr(pf0) to suppress the automatic
cleanup and properly transfer ownership to the caller.
Fixes: 3225f52cde56 ("PCI/TSM: Establish Secure Sessions and Link Encryption")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/pci/tsm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/tsm.c b/drivers/pci/tsm.c
index 5fdcd7f2e820..dd4e0cb0c6aa 100644
--- a/drivers/pci/tsm.c
+++ b/drivers/pci/tsm.c
@@ -670,7 +670,7 @@ static struct pci_dev *find_dsm_dev(struct pci_dev *pdev)
return NULL;
if (is_dsm(pf0))
- return pf0;
+ return no_free_ptr(pf0);
/*
* For cases where a switch may be hosting TDISP services on behalf of
--
2.34.1
next reply other threads:[~2026-06-16 3:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 3:02 Wentao Liang [this message]
2026-06-16 3:16 ` Lukas Wunner
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=20260616030243.1661791-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=bhelgaas@google.com \
--cc=djbw@kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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®