linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI/AER: potential dereference of null pointer
@ 2021-12-09  9:45 Jiasheng Jiang
  2021-12-11 17:54 ` Bjorn Helgaas
  0 siblings, 1 reply; 4+ messages in thread
From: Jiasheng Jiang @ 2021-12-09  9:45 UTC (permalink / raw)
  To: ruscur, oohall, bhelgaas
  Cc: linuxppc-dev, linux-pci, linux-kernel, Jiasheng Jiang

he return value of kzalloc() needs to be checked.
To avoid use of null pointer in case of the failure of alloc.

Fixes: db89ccbe52c7 ("PCI/AER: Define aer_stats structure for AER capable devices")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/pci/pcie/aer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index ec943cee5ecc..d04303edf468 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -376,6 +376,8 @@ void pci_aer_init(struct pci_dev *dev)
 		return;
 
 	dev->aer_stats = kzalloc(sizeof(struct aer_stats), GFP_KERNEL);
+	if (!dev->aer_stats)
+		return;
 
 	/*
 	 * We save/restore PCI_ERR_UNCOR_MASK, PCI_ERR_UNCOR_SEVER,
-- 
2.25.1


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

end of thread, other threads:[~2021-12-13 20:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09  9:45 [PATCH] PCI/AER: potential dereference of null pointer Jiasheng Jiang
2021-12-11 17:54 ` Bjorn Helgaas
2021-12-13 19:57   ` Rajat Jain
2021-12-13 20:07     ` Bjorn Helgaas

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