Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers/net/irda/pxaficp_ir.c: fix error return code

The function pxa_irda_probe() return 0 for success and negative value
for most of its internal tests failures. There is one exception
that is error case going to err_mem_3:. For this error case, the
function abort its success execution path, but returns non negative
value, making it difficult for a caller function to notice the error.

This patch fixes the error case that do not return negative value.

This was found by Coccinelle, but the code change was made by hand.
This patch is not robot generated.

A simplified version of the semantic match that finds this problem is
as follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
when != &ret
*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>

Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Peter Senna Tschudin and committed by
David S. Miller
cbd841ca 6734011f

+3 -1
+3 -1
drivers/net/irda/pxaficp_ir.c
··· 846 846 goto err_mem_2; 847 847 848 848 dev = alloc_irdadev(sizeof(struct pxa_irda)); 849 - if (!dev) 849 + if (!dev) { 850 + err = -ENOMEM; 850 851 goto err_mem_3; 852 + } 851 853 852 854 SET_NETDEV_DEV(dev, &pdev->dev); 853 855 si = netdev_priv(dev);