From: Bjorn Helgaas <helgaas@kernel.org>
To: Samasth Norway Ananda <samasth.norway.ananda@oracle.com>
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
Mario Limonciello <mario.limonciello@amd.com>
Subject: Re: [PATCH] x86/PCI: Fix Null pointer dereference after call to pcie_find_root_port()
Date: Mon, 12 Aug 2024 15:51:59 -0500 [thread overview]
Message-ID: <20240812205159.GA294028@bhelgaas> (raw)
In-Reply-To: <20240812202659.1649121-1-samasth.norway.ananda@oracle.com>
[+cc Mario, 7d08f21f8c63 author]
On Mon, Aug 12, 2024 at 01:26:59PM -0700, Samasth Norway Ananda wrote:
> If pcie_find_root_port() is unable to locate a root port, it will return
> NULL. This NULL pointer needs to be handled before trying to dereference.
>
> Fixes: 7d08f21f8c63 ("x86/PCI: Avoid PME from D3hot/D3cold for AMD Rembrandt and Phoenix USB4")
> Signed-off-by: Samasth Norway Ananda <samasth.norway.ananda@oracle.com>
> ---
> arch/x86/pci/fixup.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c
> index b33afb240601..98a9bb92d75c 100644
> --- a/arch/x86/pci/fixup.c
> +++ b/arch/x86/pci/fixup.c
> @@ -980,7 +980,7 @@ static void amd_rp_pme_suspend(struct pci_dev *dev)
> return;
>
> rp = pcie_find_root_port(dev);
> - if (!rp->pm_cap)
> + if (!rp || !rp->pm_cap)
Seems reasonable. I suspect we haven't seen problems because these
quirks are limited to Device IDs that are all PCIe, but I think we
should check on principle and because it may be copied elsewhere where
it *does* matter.
> return;
>
> rp->pme_support &= ~((PCI_PM_CAP_PME_D3hot|PCI_PM_CAP_PME_D3cold) >>
> @@ -994,7 +994,7 @@ static void amd_rp_pme_resume(struct pci_dev *dev)
> u16 pmc;
>
> rp = pcie_find_root_port(dev);
> - if (!rp->pm_cap)
> + if (!rp || !rp->pm_cap)
> return;
>
> pci_read_config_word(rp, rp->pm_cap + PCI_PM_PMC, &pmc);
> --
> 2.45.2
>
next prev parent reply other threads:[~2024-08-12 20:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-12 20:26 [PATCH] x86/PCI: Fix Null pointer dereference after call to pcie_find_root_port() Samasth Norway Ananda
2024-08-12 20:51 ` Bjorn Helgaas [this message]
2024-08-20 21:01 ` Mario Limonciello
2024-08-20 23:36 ` Bjorn Helgaas
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=20240812205159.GA294028@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=linux-pci@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=samasth.norway.ananda@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.