]> git.baikalelectronics.ru Git - kernel.git/commit
USB: gadget: Return -ENOMEM on memory allocation failure
authorJulia Lawall <julia@diku.dk>
Wed, 11 Aug 2010 10:10:48 +0000 (12:10 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 24 Aug 2010 03:50:16 +0000 (20:50 -0700)
commit58ed3fae32731d64c8f62028c136513884e77ec1
tree4e98fbe0298e523231fa6b7d470d640d364aa712
parent3e4f52f8463205cad018869ecf6f0bb144902987
USB: gadget: Return -ENOMEM on memory allocation failure

In this code, 0 is returned on memory allocation failure, even though other
failures return -ENOMEM or other similar values.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression ret;
expression x,e1,e2,e3;
@@

ret = 0
... when != ret = e1
*x = \(kmalloc\|kcalloc\|kzalloc\)(...)
... when != ret = e2
if (x == NULL) { ... when != ret = e3
  return ret;
}
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/gadget/m66592-udc.c