Skip to content

Commit c2bb7bc

Browse files
musicakcdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 08a965e commit c2bb7bc

File tree

1 file changed

+2
-2
lines changed
  • drivers/net/ethernet/marvell

1 file changed

+2
-2
lines changed

drivers/net/ethernet/marvell/mvpp2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,7 +3061,7 @@ static int mvpp2_prs_mac_da_accept(struct mvpp2 *priv, int port,
30613061

30623062
pe = kzalloc(sizeof(*pe), GFP_KERNEL);
30633063
if (!pe)
3064-
return -1;
3064+
return -ENOMEM;
30653065
mvpp2_prs_tcam_lu_set(pe, MVPP2_PRS_LU_MAC);
30663066
pe->index = tid;
30673067

@@ -3077,7 +3077,7 @@ static int mvpp2_prs_mac_da_accept(struct mvpp2 *priv, int port,
30773077
if (pmap == 0) {
30783078
if (add) {
30793079
kfree(pe);
3080-
return -1;
3080+
return -EINVAL;
30813081
}
30823082
mvpp2_prs_hw_inv(priv, pe->index);
30833083
priv->prs_shadow[pe->index].valid = false;

0 commit comments

Comments
 (0)