All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] net: cavium: liquidio: Return correct error code
@ 2016-02-04 13:55 Amitoj Kaur Chawla
  2016-02-13 10:58 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-04 13:55 UTC (permalink / raw)
  To: derek.chickles, satananda.burla, felix.manlunas, raghu.vatsavayi,
	netdev, linux-kernel
  Cc: julia.lawall

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>
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c    | 2 +-
 drivers/net/ethernet/cavium/liquidio/octeon_droq.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index f683d97..0bf03b1 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -1685,7 +1685,7 @@ static int octeon_setup_droq(struct octeon_device *oct, int q_no, int num_descs,
 	dev_dbg(&oct->pci_dev->dev, "Creating Droq: %d\n", q_no);
 	/* droq creation and local register settings. */
 	ret_val = octeon_create_droq(oct, q_no, num_descs, desc_size, app_ctx);
-	if (ret_val == -1)
+	if (ret_val < 0)
 		return ret_val;
 
 	if (ret_val == 1) {
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
index 4dba86e..174072b 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
@@ -983,5 +983,5 @@ int octeon_create_droq(struct octeon_device *oct,
 
 create_droq_fail:
 	octeon_delete_droq(oct, q_no);
-	return -1;
+	return -ENOMEM;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/3] net: cavium: liquidio: Return correct error code
  2016-02-04 13:55 [PATCH 1/3] net: cavium: liquidio: Return correct error code Amitoj Kaur Chawla
@ 2016-02-13 10:58 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-02-13 10:58 UTC (permalink / raw)
  To: amitoj1606
  Cc: derek.chickles, satananda.burla, felix.manlunas, raghu.vatsavayi,
	netdev, linux-kernel, julia.lawall

From: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Date: Thu, 4 Feb 2016 19:25:13 +0530

> 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:
 ...
> 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>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-02-13 10:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-04 13:55 [PATCH 1/3] net: cavium: liquidio: Return correct error code Amitoj Kaur Chawla
2016-02-13 10:58 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.