linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI/AER: Fix NULL pointer access by aer_info
@ 2025-09-04 18:25 Vernon Yang
  2025-09-11 13:30 ` Vernon Yang
  2025-09-11 22:54 ` Bjorn Helgaas
  0 siblings, 2 replies; 4+ messages in thread
From: Vernon Yang @ 2025-09-04 18:25 UTC (permalink / raw)
  To: mahesh, bhelgaas, oohall
  Cc: linuxppc-dev, linux-pci, linux-kernel, Vernon Yang

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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-09-11 23:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-09-11 23:41   ` Keith Busch

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).