* [PATCH 3/20 V2] drivers/net/can/sja1000/peak_pci.c: fix error return code
[not found] <1349469667-6137-1-git-send-email-peter.senna@gmail.com>
@ 2012-10-05 20:41 ` Peter Senna Tschudin
2012-10-05 21:06 ` Marc Kleine-Budde
2012-10-07 18:38 ` David Miller
2012-10-05 20:41 ` [PATCH 4/20 V2] drivers/net/can/sja1000/peak_pcmcia.c: " Peter Senna Tschudin
1 sibling, 2 replies; 6+ messages in thread
From: Peter Senna Tschudin @ 2012-10-05 20:41 UTC (permalink / raw)
To: wg
Cc: mkl, davem, jj, linux-can, netdev, linux-kernel, kernel-janitors,
Peter Senna Tschudin
From: Peter Senna Tschudin <peter.senna@gmail.com>
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>
Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
---
Change from V1:
Updated commit message. See:
http://www.kernelhub.org/?p=2&msg=139319
drivers/net/can/sja1000/peak_pci.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/can/sja1000/peak_pci.c b/drivers/net/can/sja1000/peak_pci.c
index f0a1296..f5b82ae 100644
--- a/drivers/net/can/sja1000/peak_pci.c
+++ b/drivers/net/can/sja1000/peak_pci.c
@@ -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;
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/20 V2] drivers/net/can/sja1000/peak_pcmcia.c: fix error return code
[not found] <1349469667-6137-1-git-send-email-peter.senna@gmail.com>
2012-10-05 20:41 ` [PATCH 3/20 V2] drivers/net/can/sja1000/peak_pci.c: fix error return code Peter Senna Tschudin
@ 2012-10-05 20:41 ` Peter Senna Tschudin
2012-10-05 21:07 ` Marc Kleine-Budde
2012-10-07 18:38 ` David Miller
1 sibling, 2 replies; 6+ messages in thread
From: Peter Senna Tschudin @ 2012-10-05 20:41 UTC (permalink / raw)
To: wg
Cc: mkl, linux, linux-can, netdev, linux-kernel, kernel-janitors,
Peter Senna Tschudin
From: Peter Senna Tschudin <peter.senna@gmail.com>
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>
Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
---
Change from V1:
Updated commit message. See:
http://www.kernelhub.org/?p=2&msg=139319
drivers/net/can/sja1000/peak_pcmcia.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/sja1000/peak_pcmcia.c b/drivers/net/can/sja1000/peak_pcmcia.c
index ec6bd9d..272a85f 100644
--- a/drivers/net/can/sja1000/peak_pcmcia.c
+++ b/drivers/net/can/sja1000/peak_pcmcia.c
@@ -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);
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/20 V2] drivers/net/can/sja1000/peak_pci.c: fix error return code
2012-10-05 20:41 ` [PATCH 3/20 V2] drivers/net/can/sja1000/peak_pci.c: fix error return code Peter Senna Tschudin
@ 2012-10-05 21:06 ` Marc Kleine-Budde
2012-10-07 18:38 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: Marc Kleine-Budde @ 2012-10-05 21:06 UTC (permalink / raw)
To: Peter Senna Tschudin
Cc: wg, davem, jj, linux-can, netdev, linux-kernel, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1437 bytes --]
On 10/05/2012 10:41 PM, Peter Senna Tschudin wrote:
> From: Peter Senna Tschudin <peter.senna@gmail.com>
>
> 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>
>
> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
Too late, v1 of this patch is already in net/master
regards, Marc
--
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 |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 4/20 V2] drivers/net/can/sja1000/peak_pcmcia.c: fix error return code
2012-10-05 20:41 ` [PATCH 4/20 V2] drivers/net/can/sja1000/peak_pcmcia.c: " Peter Senna Tschudin
@ 2012-10-05 21:07 ` Marc Kleine-Budde
2012-10-07 18:38 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: Marc Kleine-Budde @ 2012-10-05 21:07 UTC (permalink / raw)
To: Peter Senna Tschudin
Cc: wg, linux, linux-can, netdev, linux-kernel, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1433 bytes --]
On 10/05/2012 10:41 PM, Peter Senna Tschudin wrote:
> From: Peter Senna Tschudin <peter.senna@gmail.com>
>
> 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>
>
> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
Too late, v1 of this patch is already in net/master
regards, Marc
--
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 |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/20 V2] drivers/net/can/sja1000/peak_pci.c: fix error return code
2012-10-05 20:41 ` [PATCH 3/20 V2] drivers/net/can/sja1000/peak_pci.c: fix error return code Peter Senna Tschudin
2012-10-05 21:06 ` Marc Kleine-Budde
@ 2012-10-07 18:38 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2012-10-07 18:38 UTC (permalink / raw)
To: peter.senna; +Cc: wg, mkl, jj, linux-can, netdev, linux-kernel, kernel-janitors
This patch was already in the tree.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 4/20 V2] drivers/net/can/sja1000/peak_pcmcia.c: fix error return code
2012-10-05 20:41 ` [PATCH 4/20 V2] drivers/net/can/sja1000/peak_pcmcia.c: " Peter Senna Tschudin
2012-10-05 21:07 ` Marc Kleine-Budde
@ 2012-10-07 18:38 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2012-10-07 18:38 UTC (permalink / raw)
To: peter.senna
Cc: wg, mkl, linux, linux-can, netdev, linux-kernel, kernel-janitors
This patch was already in the tree.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-10-07 18:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1349469667-6137-1-git-send-email-peter.senna@gmail.com>
2012-10-05 20:41 ` [PATCH 3/20 V2] drivers/net/can/sja1000/peak_pci.c: fix error return code Peter Senna Tschudin
2012-10-05 21:06 ` Marc Kleine-Budde
2012-10-07 18:38 ` David Miller
2012-10-05 20:41 ` [PATCH 4/20 V2] drivers/net/can/sja1000/peak_pcmcia.c: " Peter Senna Tschudin
2012-10-05 21:07 ` Marc Kleine-Budde
2012-10-07 18:38 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).