Skip to content

Commit 0a27bdb

Browse files
Vernon Yangbjorn-helgaas
authored andcommitted
PCI/AER: Fix NULL pointer access by aer_info
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> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://patch.msgid.link/20250904182527.67371-1-vernon2gm@gmail.com
1 parent c8ab5e8 commit 0a27bdb

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/pci/pcie/aer.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,10 @@ void pci_aer_init(struct pci_dev *dev)
393393
return;
394394

395395
dev->aer_info = kzalloc(sizeof(*dev->aer_info), GFP_KERNEL);
396+
if (!dev->aer_info) {
397+
dev->aer_cap = 0;
398+
return;
399+
}
396400

397401
ratelimit_state_init(&dev->aer_info->correctable_ratelimit,
398402
DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST);

0 commit comments

Comments
 (0)