Skip to content

Commit

Permalink
bonding: Return correct error code
Browse files Browse the repository at this point in the history
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;
@@

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

The single call site only checks that the return value is not 0,
hence no change is required at the call site.

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Amitoj Kaur Chawla authored and David S. Miller committed Feb 11, 2016
1 parent e7e9956 commit 6d9b6f4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/bonding/bond_alb.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static int tlb_initialize(struct bonding *bond)

new_hashtbl = kzalloc(size, GFP_KERNEL);
if (!new_hashtbl)
return -1;
return -ENOMEM;

spin_lock_bh(&bond->mode_lock);

Expand Down

0 comments on commit 6d9b6f4

Please sign in to comment.