Skip to content

Commit 08a965e

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

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

drivers/net/ethernet/cavium/liquidio/lio_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,7 @@ static int octeon_setup_droq(struct octeon_device *oct, int q_no, int num_descs,
16831683
dev_dbg(&oct->pci_dev->dev, "Creating Droq: %d\n", q_no);
16841684
/* droq creation and local register settings. */
16851685
ret_val = octeon_create_droq(oct, q_no, num_descs, desc_size, app_ctx);
1686-
if (ret_val == -1)
1686+
if (ret_val < 0)
16871687
return ret_val;
16881688

16891689
if (ret_val == 1) {

drivers/net/ethernet/cavium/liquidio/octeon_droq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,5 +983,5 @@ int octeon_create_droq(struct octeon_device *oct,
983983

984984
create_droq_fail:
985985
octeon_delete_droq(oct, q_no);
986-
return -1;
986+
return -ENOMEM;
987987
}

0 commit comments

Comments
 (0)