2005-03-06 18:21:48

by Panagiotis Issaris

[permalink] [raw]
Subject: [PATCH 2.6.11-mm1] 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]>

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);