Skip to contentSkip to conversation

acpiphp_ibm: add failure handling for memory allocation

PATCH New Panagiotis Issaris 1 participant 1 message Mar 6, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 acpiphp_ibm: add failure handling for memory allocation

Hi,

This patch adds failure handling for kmalloc in the ACPI PCI Hot Plug IBM Extension driver.

Signed-off-by <[email protected]>
drivers/pci/hotplug/acpiphp_ibm.c +5 -0
diff -pruN linux-2.6.11-orig/drivers/pci/hotplug/acpiphp_ibm.c linux-2.6.11-pi/drivers/pci/hotplug/acpiphp_ibm.c
@@ -163,6 +163,11 @@ static union apci_descriptor *ibm_slot_f
 ibm_slot_done:
 	if (ret) {
 		ret = kmalloc(sizeof(union apci_descriptor), GFP_KERNEL);
+		if (!ret) {
+			err("%s:  Memory allocation failed.\n", __FUNCTION__);
+			kfree(table);
+			return -ENOMEM;
+		}
 		memcpy(ret, des, sizeof(union apci_descriptor));
 	}
 	kfree(table);