Re: [PATCH] aironet4500_cs.c kmalloc checking

From: Jeff Garzik (jgarzik@mandrakesoft.com)
Date: Tue Aug 08 2000 - 14:07:42 EST


Arnaldo Carvalho de Melo wrote:
> static const char *awc_version =
> -"aironet4500_cs.c v0.1 1/1/99 Elmer Joandi, elmer@ylenurme.ee.\n";
> +"aironet4500_cs.c v0.2 1/1/99 Elmer Joandi, elmer@ylenurme.ee.\n";

should update the date, too.

> /* Create the PC card device object. */
> link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
> - memset(link, 0, sizeof(struct dev_link_t));
> + if (!link)
> + return NULL;
> +
> link->dev = kmalloc(sizeof(struct dev_node_t), GFP_KERNEL);
> +
> + if (!link->dev) {
> + kfree(link);
> + return NULL;
> + }
> +
> + memset(link, 0, sizeof(struct dev_link_t));
> memset(link->dev, 0, sizeof(struct dev_node_t));

I would suggest turning this patch into one similar to your ray_cs
patch: create a few goto labels at the bottom of the function for
cleanup, and call those whenever any error condition occurs. This will
remove the code duplication which exists after applying your patch, and
also isolate the error handling code into one location.

        Jeff

-- 
Jeff Garzik              |
Building 1024            | Yossarian lives.
MandrakeSoft, Inc.       |

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Aug 15 2000 - 21:00:15 EST