From: Julia Lawall Date: Wed, 20 May 2009 07:17:11 +0000 (+0200) Subject: Staging: cpc-usb: Adjust NULL test X-Git-Tag: MMI-PSA29.97-13-9~27688^2~50 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a3d97c9b192df8e9c6a041f9452b400070ce2d02;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git Staging: cpc-usb: Adjust NULL test Since card must already be non-NULL, it seems that what was intended was to test the result of kmalloc. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ expression E,E1; identifier f,fld,fld1; statement S1,S2; @@ E->fld = f(...); ... when != E = E1 when != E->fld1 = E1 if ( - E + E->fld == NULL) S1 else S2 // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/cpc-usb/cpc-usb_drv.c b/drivers/staging/cpc-usb/cpc-usb_drv.c index 14aca399fc4c..672f7866a69c 100644 --- a/drivers/staging/cpc-usb/cpc-usb_drv.c +++ b/drivers/staging/cpc-usb/cpc-usb_drv.c @@ -899,7 +899,7 @@ static int cpcusb_probe(struct usb_interface *interface, /* allocate and initialize the channel struct */ card->chan = kmalloc(sizeof(CPC_CHAN_T), GFP_KERNEL); - if (!card) { + if (!card->chan) { kfree(card); err("Out of memory"); return -ENOMEM;