[Skiboot] [PATCH v2] Introduce memory allocation return value check

Kamalesh Babulal kamalesh at linux.vnet.ibm.com
Wed Jun 24 16:11:24 AEST 2015


In pci_std_swizzle_irq_map(), check if the memory allocation
of interrupt-mask returns a valid pointer before using it.

Fixes Coverity defect#97854.

Signed-off-by: Kamalesh Babulal <kamalesh at linux.vnet.ibm.com>
Cc: Samuel Mendoza-Jonas <sam.mj at au1.ibm.com>
Cc: Gavin Shan <gwshan at linux.vnet.ibm.com>
---
 core/pci.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/core/pci.c b/core/pci.c
index 8f8aeeb..1b56d73 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -1086,6 +1086,10 @@ void pci_std_swizzle_irq_map(struct dt_node *np,
 	}
 	map_size = esize * edevcount * 4 * sizeof(uint32_t);
 	map = p = zalloc(map_size);
+	if (!map) {
+		prlog(PR_DEBUG, "Failed to allocate interrupt-map-mask !\n");
+		return;
+	}
 
 	for (dev = 0; dev < edevcount; dev++) {
 		for (irq = 0; irq < 4; irq++) {
-- 
2.1.2



More information about the Skiboot mailing list