]> git.baikalelectronics.ru Git - kernel.git/commit
net: mvpp2: Return correct error codes
authorAmitoj Kaur Chawla <amitoj1606@gmail.com>
Thu, 4 Feb 2016 13:55:26 +0000 (19:25 +0530)
committerDavid S. Miller <davem@davemloft.net>
Sat, 13 Feb 2016 10:57:39 +0000 (05:57 -0500)
commit69b2a426884f783f79fdc30686ba35c9abbc2b3d
treeaeee4608dde580375a9c3795cdf5602d1628ea3c
parent16b444057dce1a53a5f2d874293c832dc5526784
net: mvpp2: Return correct error codes

The return value of kzalloc 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;
position p,q;
@@

e@q = kzalloc(...);
if@p (e == NULL) {
...
return
- -1
+ -ENOMEM
;
}
//</smpl>

This function may also return -1 after calling mpp2_prs_tcam_port_map_get.
So that the function consistently returns meaningful error values on
failure, the -1 is changed to -EINVAL.

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