From: Niklas Cassel <cassel@kernel.org>
To: Hongyan Xu <getshell@seu.edu.cn>
Cc: Damien Le Moal <dlemoal@kernel.org>,
linux-ide@vger.kernel.org, jianhao.xu@seu.edu.cn
Subject: Re: [PATCH] ata: pata_sl82c105: fix bridge revision use-after-free
Date: Thu, 6 Aug 2026 13:55:46 +0200 [thread overview]
Message-ID: <anR2QnAEP3FOzjwG@ryzen> (raw)
In-Reply-To: <20260806060628.1658-1-getshell@seu.edu.cn>
On Thu, Aug 06, 2026 at 02:06:28PM +0800, Hongyan Xu wrote:
> pci_get_slot() returns a referenced PCI device. Commit 44c10138fd4b
> ("PCI: Change all drivers to use pci_device->revision") replaced a
> configuration-space read with direct access to the cached revision field,
> but left that access after pci_dev_put(). The bridge may therefore be freed
> before its revision is read.
>
> Read the revision before dropping the reference.
>
> Fixes: 44c10138fd4b ("PCI: Change all drivers to use pci_device->revision")
> Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
> ---
> drivers/ata/pata_sl82c105.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c
> index 2d24c6b3e9d9..25bce3fe2a10 100644
> --- a/drivers/ata/pata_sl82c105.c
> +++ b/drivers/ata/pata_sl82c105.c
> @@ -264,6 +264,7 @@ static struct ata_port_operations sl82c105_port_ops = {
> static int sl82c105_bridge_revision(struct pci_dev *pdev)
> {
> struct pci_dev *bridge;
> + u8 revision;
>
> /*
> * The bridge should be part of the same device, but function 0.
> @@ -285,8 +286,9 @@ static int sl82c105_bridge_revision(struct pci_dev *pdev)
> /*
> * We need to find function 0's revision, not function 1
> */
> + revision = bridge->revision;
> pci_dev_put(bridge);
> - return bridge->revision;
> + return revision;
> }
>
> static void sl82c105_fixup(struct pci_dev *pdev)
> --
> 2.50.1.windows.1
>
Makes sense to me:
Reviewed-by: Niklas Cassel <cassel@kernel.org>
next prev parent reply other threads:[~2026-08-06 11:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 6:06 [PATCH] ata: pata_sl82c105: fix bridge revision use-after-free Hongyan Xu
2026-08-06 11:55 ` Niklas Cassel [this message]
2026-08-06 15:56 ` Damien Le Moal
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=anR2QnAEP3FOzjwG@ryzen \
--to=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=getshell@seu.edu.cn \
--cc=jianhao.xu@seu.edu.cn \
--cc=linux-ide@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