drivers/net/ethernet/dec/tulip/dmfe.c: fix error return code
Subsystems (8)
PATCH v2 1/20 drivers/net/ethernet/dec/tulip/dmfe.c: fix error return code
From: Peter Senna Tschudin <[email protected]>
The function dmfe_init_one() return 0 for success and negative value for most of its internal tests failures. There are three exceptions that are error cases going to err_out_*:. Fore this three cases the function abort its success execution path, but returns non negative value, making it dificult for a caller function to notice the error.
This patch fixes the error cases that do not return negative values.
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>
---
Changes from V1:
Updated commit message. See: http://www.kernelhub.org/?p=2&msg9319
drivers/net/ethernet/dec/tulip/dmfe.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/dec/tulip/dmfe.c +9 -3
@@ -446,13 +446,17 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,/* Allocate Tx/Rx descriptor memory */ db->desc_pool_ptr =pci_alloc_consistent (pdev,sizeof (struct tx_desc ) *DESC_ALL_CNT +0x20 , &db->desc_pool_dma_ptr); -if (!db->desc_pool_ptr) +if (!db->desc_pool_ptr) { + err = -ENOMEM ; goto err_out_res; + } db->buf_pool_ptr =pci_alloc_consistent (pdev,TX_BUF_ALLOC *TX_DESC_CNT +4 , &db->buf_pool_dma_ptr); -if (!db->buf_pool_ptr) +if (!db->buf_pool_ptr) { + err = -ENOMEM ; goto err_out_free_desc; + } db->first_tx_desc = (struct tx_desc *) db->desc_pool_ptr; db->first_tx_desc_dma = db->desc_pool_dma_ptr;
@@ -462,8 +466,10 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev, db->chip_id = ent->driver_data;/* IO type range. */ db->ioaddr =pci_iomap (pdev,0 ,0 ); -if (!db->ioaddr) +if (!db->ioaddr) { + err = -ENOMEM ; goto err_out_free_buf; + } db->chip_revision = pdev->revision; db->wol_mode =0 ;
PATCH v2 2/20 drivers/net/ethernet/natsemi/natsemi.c: fix error return code
From: Peter Senna Tschudin <[email protected]>
The function natsemi_probe1() 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_create_file:. Fore 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>
---
Changes from V1:
Updated commit message. See: http://www.kernelhub.org/?p=2&msg9319
drivers/net/ethernet/natsemi/natsemi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/natsemi/natsemi.c +2 -2
@@ -947,8 +947,8 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev, i =register_netdev (dev);if (i) goto err_register_netdev; - -if (NATSEMI_CREATE_FILE (pdev, dspcfg_workaround)) + i =NATSEMI_CREATE_FILE (pdev, dspcfg_workaround); +if (i) goto err_create_file;if (netif_msg_drv (np)) {
Re: [PATCH 2/20 V2] drivers/net/ethernet/natsemi/natsemi.c: fix error return code
Peter Senna Tschudin <[email protected]> :
[...]
Quoted 5 lines
The function
natsemi_probe1()return 0 for success and negative value for most of its internal tests failures. There is one exception that is error case going toerr_create_file:. Fore 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.
Ok. natsemi_probe1() forgets to return a negative status code in one of its failure paths.
[...]
Quoted 1 line
Signed-off-by Peter Senna Tschudin <[email protected]>
Signature · 1 line
Ueimor
Re: [PATCH 2/20 V2] drivers/net/ethernet/natsemi/natsemi.c: fix error return code
In reply to Peter Senna TschudinApplied.
PATCH v2 3/20 drivers/net/can/sja1000/peak_pci.c: fix error return code
In reply to Peter Senna TschudinFrom: Peter Senna Tschudin <[email protected]>
The function peak_pci_probe() return 0 for success and negative value for most of its internal tests failures. There are two exceptions that are error cases going to failure_*:. Fore this two cases the function abort its success execution path, but returns non negative value, making it dificult for a caller function to notice the error.
This patch fixes the error cases that do not return negative values.
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>
---
Change from V1:
Updated commit message. See: http://www.kernelhub.org/?p=2&msg9319
drivers/net/can/sja1000/peak_pci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/can/sja1000/peak_pci.c +2 -0
@@ -583,12 +583,14 @@ static int __devinit peak_pci_probe(struct pci_dev *pdev, cfg_base =pci_iomap (pdev,0 ,PEAK_PCI_CFG_SIZE );if (!cfg_base) {dev_err (&pdev->dev,"failed to map PCI resource #0\n" ); + err = -ENOMEM ; goto failure_release_regions; } reg_base =pci_iomap (pdev,1 ,PEAK_PCI_CHAN_SIZE * channels);if (!reg_base) {dev_err (&pdev->dev,"failed to map PCI resource #1\n" ); + err = -ENOMEM ; goto failure_unmap_cfg_base; }
Marc Kleine-Budde
maintainerRe: [PATCH 3/20 V2] drivers/net/can/sja1000/peak_pci.c: fix error return code
Quoted 33 lines · Peter Senna Tschudin
From: Peter Senna Tschudin <[email protected]>
The function
peak_pci_probe()return 0 for success and negative value for most of its internal tests failures. There are two exceptions that are error cases going to failure_*:. Fore this two cases the function abort its success execution path, but returns non negative value, making it dificult for a caller function to notice the error.This patch fixes the error cases that do not return negative values.
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 = e1when != &ret*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>
Quoted 1 line
Signed-off-by Peter Senna Tschudin <[email protected]>
Too late, v1 of this patch is already in net/master
regards, Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
David Miller
maintainerRe: [PATCH 3/20 V2] drivers/net/can/sja1000/peak_pci.c: fix error return code
In reply to Peter Senna TschudinThis patch was already in the tree.
PATCH v2 4/20 drivers/net/can/sja1000/peak_pcmcia.c: fix error return code
In reply to Peter Senna TschudinFrom: Peter Senna Tschudin <[email protected]>
The function pcan_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 probe_err_4:. Fore 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>
---
Change from V1:
Updated commit message. See:
http://www.kernelhub.org/?p=2&msg9319
drivers/net/can/sja1000/peak_pcmcia.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/can/sja1000/peak_pcmcia.c +3 -1
@@ -686,8 +686,10 @@ static int __devinit pcan_probe(struct pcmcia_device *pdev)/* detect available channels */ pcan_add_channels (card); -if (!card->chan_count) +if (!card->chan_count) { + err = -ENOMEM ; goto probe_err_4; + }/* init the timer which controls the leds */ init_timer (&card->led_timer);
Marc Kleine-Budde
maintainerRe: [PATCH 4/20 V2] drivers/net/can/sja1000/peak_pcmcia.c: fix error return code
Quoted 33 lines · Peter Senna Tschudin
From: Peter Senna Tschudin <[email protected]>
The function
pcan_probe()return 0 for success and negative value for most of its internal tests failures. There is one exception that is error case going toprobe_err_4:. Fore 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 = e1when != &ret*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>
Quoted 1 line
Signed-off-by Peter Senna Tschudin <[email protected]>
Too late, v1 of this patch is already in net/master
regards, Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
David Miller
maintainerRe: [PATCH 4/20 V2] drivers/net/can/sja1000/peak_pcmcia.c: fix error return code
In reply to Peter Senna TschudinThis patch was already in the tree.
PATCH v2 5/20 drivers/net/ethernet/sis/sis900.c: fix error return code
In reply to Peter Senna TschudinFrom: Peter Senna Tschudin <[email protected]>
The function sis900_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_out_cleardev:. Fore 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>
---
Change from V1:
Updated commit message. See:
http://www.kernelhub.org/?p=2&msg9319
drivers/net/ethernet/sis/sis900.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/sis/sis900.c +3 -1
@@ -478,8 +478,10 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,/* IO region. */ ioaddr =pci_iomap (pci_dev,0 ,0 ); -if (!ioaddr) +if (!ioaddr) { + ret = -ENOMEM ; goto err_out_cleardev; + } sis_priv =netdev_priv (net_dev); sis_priv->ioaddr = ioaddr;
Re: [PATCH 5/20 V2] drivers/net/ethernet/sis/sis900.c: fix error return code
Applied.
Applied.