lkml.org 
[lkml]   [2000]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] aironet4500_cs.c kmalloc checking
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/

\
 
 \ /
  Last update: 2005-03-22 13:58    [W:0.078 / U:1.992 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site