Skip to contentSkip to conversation

ibm_emac_core: add memory allocation failure handling

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ibm_emac_core: add memory allocation failure handling

Hi,

This patch adds failure handling for a kmalloc() in the driver for the IBM 4xx PowerPC builtin ethernet.

Signed-off-by <[email protected]>
drivers/net/ibm_emac/ibm_emac_core.c +5 -0
diff -pruN linux-2.6.11-orig/drivers/net/ibm_emac/ibm_emac_core.c linux-2.6.11-pi/drivers/net/ibm_emac/ibm_emac_core.c
@@ -1957,6 +1957,11 @@ static int emac_probe(struct ocp_device 
 		struct emac_def_dev *ddev;
 		/* Add this index to the deferred init table */
 		ddev = kmalloc(sizeof(struct emac_def_dev), GFP_KERNEL);
+		if (!ddev) {
+			printk(KERN_ERR "emac%d: Memory allocation failed.\n", 
+					ocpdev->def->index);
+			return -ENOMEM;
+		}
 		ddev->ocpdev = ocpdev;
 		ddev->mal = mal;
 		list_add_tail(&ddev->link, &emac_init_list);