[PATCH 2.6.11-mm1] ibm_emac_core: add memory allocation failure handling

From: Panagiotis Issaris
Date: Sun Mar 06 2005 - 13:23:58 EST


Hi,

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

Signed-off-by: <panagiotis.issaris@xxxxxxxxxxxxxxxxxxx>

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
--- linux-2.6.11-orig/drivers/net/ibm_emac/ibm_emac_core.c 2005-03-05 03:30:09.000000000 +0100
+++ linux-2.6.11-pi/drivers/net/ibm_emac/ibm_emac_core.c 2005-03-06 19:00:10.000000000 +0100
@@ -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);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/