[PATCH] x86/PCI: add a check for alloc_pci_root_info()

Haoxiang Li posted 1 patch 1 month, 2 weeks ago
arch/x86/pci/broadcom_bus.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] x86/PCI: add a check for alloc_pci_root_info()
Posted by Haoxiang Li 1 month, 2 weeks ago
Add a return value check for alloc_pci_root_info() to
prevent null pointer dereference in update_res().

Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
 arch/x86/pci/broadcom_bus.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/pci/broadcom_bus.c b/arch/x86/pci/broadcom_bus.c
index 2db73613cada..d0cf7d2acc65 100644
--- a/arch/x86/pci/broadcom_bus.c
+++ b/arch/x86/pci/broadcom_bus.c
@@ -27,6 +27,8 @@ static void __init cnb20le_res(u8 bus, u8 slot, u8 func)
 	fbus = read_pci_config_byte(bus, slot, func, 0x44);
 	lbus = read_pci_config_byte(bus, slot, func, 0x45);
 	info = alloc_pci_root_info(fbus, lbus, 0, 0);
+	if (!info)
+		return;
 
 	/*
 	 * Add the legacy IDE ports on bus 0
-- 
2.25.1