From: Bjorn Helgaas <helgaas@kernel.org>
To: Vernon Yang <vernon2gm@gmail.com>
Cc: mahesh@linux.ibm.com, bhelgaas@google.com, oohall@gmail.com,
linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org,
Vernon Yang <yanglincheng@kylinos.cn>,
Terry Bowman <terry.bowman@amd.com>,
Robert Richter <rrichter@amd.com>,
linux-cxl@vger.kernel.org,
Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>,
Dongdong Liu <liudongdong3@huawei.com>
Subject: Re: [PATCH] PCI/AER: Fix NULL pointer access by aer_info
Date: Thu, 11 Sep 2025 17:54:57 -0500 [thread overview]
Message-ID: <20250911225457.GA1596803@bhelgaas> (raw)
In-Reply-To: <20250904182527.67371-1-vernon2gm@gmail.com>
[+cc Terry, Robert, CXL list, Smita, Dongdong]
On Fri, Sep 05, 2025 at 02:25:27AM +0800, Vernon Yang wrote:
> From: Vernon Yang <yanglincheng@kylinos.cn>
>
> The kzalloc(GFP_KERNEL) may return NULL, so all accesses to
> aer_info->xxx will result in kernel panic. Fix it.
>
> Signed-off-by: Vernon Yang <yanglincheng@kylinos.cn>
Applied to pci/aer for v6.18, thanks, Vernon!
Not directly related to this patch, but I'm concerned about some users
of dev->aer_cap.
Most users of dev->aer_cap either (a) check that it's set before using
it or (b) are called in paths obviously only reachable via an AER
interrupt.
But there are a few users of dev->aer_cap that use it without checking
it for zero, and it's not obvious to me that it must be valid:
- pci_aer_unmask_internal_errors(), added by b7e9392d5d46 ("PCI/AER:
Unmask RCEC internal errors to enable RCH downstream port error
handling")
- dpc_get_aer_uncorrect_severity(), added by 9f08a5d896ce ("PCI/DPC:
Fix print AER status in DPC event handling")
- dpc_is_surprise_removal(), added by 2ae8fbbe1cd4 ("PCI/DPC: Ignore
Surprise Down error on hot removal")
> ---
> drivers/pci/pcie/aer.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index e286c197d716..aeb2534f50dd 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -383,6 +383,10 @@ void pci_aer_init(struct pci_dev *dev)
> return;
>
> dev->aer_info = kzalloc(sizeof(*dev->aer_info), GFP_KERNEL);
> + if (!dev->aer_info) {
> + dev->aer_cap = 0;
> + return;
> + }
>
> ratelimit_state_init(&dev->aer_info->correctable_ratelimit,
> DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST);
> --
> 2.51.0
>
next prev parent reply other threads:[~2025-09-11 22:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 18:25 [PATCH] PCI/AER: Fix NULL pointer access by aer_info Vernon Yang
2025-09-11 13:30 ` Vernon Yang
2025-09-11 22:54 ` Bjorn Helgaas [this message]
2025-09-11 23:41 ` Keith Busch
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=20250911225457.GA1596803@bhelgaas \
--to=helgaas@kernel.org \
--cc=Smita.KoralahalliChannabasappa@amd.com \
--cc=bhelgaas@google.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=liudongdong3@huawei.com \
--cc=mahesh@linux.ibm.com \
--cc=oohall@gmail.com \
--cc=rrichter@amd.com \
--cc=terry.bowman@amd.com \
--cc=vernon2gm@gmail.com \
--cc=yanglincheng@kylinos.cn \
/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;
as well as URLs for NNTP newsgroup(s).