drivers/net/ax88796.c: Return error code in failure
Subsystems (3)
PATCH 2/2 drivers/net/ax88796.c: Return error code in failure
In this code, 0 is returned on failure, even though other failures return -ENOMEM or other similar values.
A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@a@
identifier alloc;
identifier ret;
constant C;
expression x;
@@
x = alloc(...);
if (x == NULL) { <+... \(ret = -C; \| return -C; \) ...+> }
@@
identifier f, a.alloc;
expression ret;
expression x,e1,e2,e3;
@@
ret = 0
... when != ret = e1
*x = alloc(...)
... when != ret = e2
if (x == NULL) { ... when != ret = e3
return ret;
}
// </smpl>
---
Another call to platform_get_resource in the same function uses -ENXIO, so I have used the same value here.
drivers/net/ax88796.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ax88796.c +1 -0
@@ -864,6 +864,7 @@ static int ax_probe(struct platform_device *pdev) res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 );if (res ==NULL ) {dev_err (&pdev->dev,"no IRQ specified\n" ); + ret = -ENXIO ; goto exit_mem; }
From: Julia Lawall <[email protected]>
Date: Mon, 18 Oct 2010 16:11:14 +0200
Quoted 5 lines
In this code, 0 is returned on failure, even though other failures return
-ENOMEMor other similar values.A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
...
Quoted 1 line
Signed-off-by Julia Lawall <[email protected]>
Applied.