From: Vernon Yang <vernon2gm@gmail.com>
To: mahesh@linux.ibm.com, bhelgaas@google.com, oohall@gmail.com
Cc: linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org,
Vernon Yang <yanglincheng@kylinos.cn>
Subject: [PATCH] PCI/AER: Fix NULL pointer access by aer_info
Date: Fri, 5 Sep 2025 02:25:27 +0800 [thread overview]
Message-ID: <20250904182527.67371-1-vernon2gm@gmail.com> (raw)
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>
---
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 reply other threads:[~2025-09-04 18:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 18:25 Vernon Yang [this message]
2025-09-11 13:30 ` [PATCH] PCI/AER: Fix NULL pointer access by aer_info Vernon Yang
2025-09-11 22:54 ` Bjorn Helgaas
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=20250904182527.67371-1-vernon2gm@gmail.com \
--to=vernon2gm@gmail.com \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mahesh@linux.ibm.com \
--cc=oohall@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).