[Skiboot] [PATCH 8/8] Introduce memory allocation return value check

Kamalesh Babulal kamalesh at linux.vnet.ibm.com
Tue Jun 23 18:37:38 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>
---
 core/pci.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/core/pci.c b/core/pci.c
index fe23d6c..ae71814 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -1087,6 +1087,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");
+		goto fail;
+	}
 
 	for (dev = 0; dev < edevcount; dev++) {
 		for (irq = 0; irq < 4; irq++) {
@@ -1111,7 +1115,9 @@ void pci_std_swizzle_irq_map(struct dt_node *np,
 	}
 
 	dt_add_property(np, "interrupt-map", map, map_size);
-	free(map);
+fail:
+	if (map)
+		free(map);
 }
 
 static void pci_add_slot_properties(struct phb *phb, struct pci_slot_info *info,
-- 
2.1.2



More information about the Skiboot mailing list