OSDN Git Service

net: cavium: liquidio: Return correct error code
authorAmitoj Kaur Chawla <amitoj1606@gmail.com>
Thu, 4 Feb 2016 13:55:13 +0000 (19:25 +0530)
committerDavid S. Miller <davem@davemloft.net>
Sat, 13 Feb 2016 10:57:11 +0000 (05:57 -0500)
commit08a965ec93ad0495802462c32b73241d658e189d
tree6bbe77e1ba15448cdc740f17fac5d8a0b19d6041
parent21a75f0915dde8674708b39abfcda113911c49b1
net: cavium: liquidio: Return correct error code

The return value of vmalloc on failure of allocation of memory should
be -ENOMEM and not -1.

Found using Coccinelle. A simplified version of the semantic patch
used is:

//<smpl>
@@
expression *e;
identifier l1;
position p,q;
@@

e@q = vmalloc(...);
if@p (e == NULL) {
...
goto l1;
}
l1:
...
return -1
+ -ENOMEM
;
//</smpl

The single call site of the containing function checks whether the
returned value is -1, so this check is changed as well. The single call
site of this call site, however, only checks whether the value is not 0,
so no further change was required.

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/cavium/liquidio/lio_main.c
drivers/net/ethernet/cavium/liquidio/octeon_droq.c