2012-08-25 19:57:15

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 0/6] adjust inconsistent IS_ERR and PTR_ERR

These patches fix cases where PTR_ERR does not access the value just tested
by IS_ERR.


2012-08-25 19:57:26

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 4/6] drivers/usb/host/ohci-nxp.c: adjust inconsistent IS_ERR and PTR_ERR

From: Julia Lawall <[email protected]>

Change the call to PTR_ERR to access the value just tested by IS_ERR.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e,e1;
@@

(
if (IS_ERR(e)) { ... PTR_ERR(e) ... }
|
if (IS_ERR(e=e1)) { ... PTR_ERR(e) ... }
|
*if (IS_ERR(e))
{ ...
* PTR_ERR(e1)
... }
)
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/usb/host/ohci-nxp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ohci-nxp.c b/drivers/usb/host/ohci-nxp.c
index a446386..c60066a 100644
--- a/drivers/usb/host/ohci-nxp.c
+++ b/drivers/usb/host/ohci-nxp.c
@@ -355,7 +355,7 @@ static int __devinit usb_hcd_nxp_probe(struct platform_device *pdev)
usb_otg_clk = clk_get(&pdev->dev, "ck_usb_otg");
if (IS_ERR(usb_otg_clk)) {
dev_err(&pdev->dev, "failed to acquire USB DEV Clock\n");
- ret = PTR_ERR(usb_dev_clk);
+ ret = PTR_ERR(usb_otg_clk);
goto out6;
}

2012-08-25 19:57:24

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 2/6] drivers/media/platform/mx2_emmaprp.c: adjust inconsistent IS_ERR and PTR_ERR

From: Julia Lawall <[email protected]>

Change the call to IS_ERR to test the value that was just initialized and
is returned using PTR_ERR.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e,e1;
@@

(
if (IS_ERR(e)) { ... PTR_ERR(e) ... }
|
if (IS_ERR(e=e1)) { ... PTR_ERR(e) ... }
|
*if (IS_ERR(e))
{ ...
* PTR_ERR(e1)
... }
)
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/media/platform/mx2_emmaprp.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c
index dab380a..2be1bb1 100644
--- a/drivers/media/platform/mx2_emmaprp.c
+++ b/drivers/media/platform/mx2_emmaprp.c
@@ -908,9 +908,8 @@ static int emmaprp_probe(struct platform_device *pdev)
}

pcdev->clk_emma_ahb = devm_clk_get(&pdev->dev, "ahb");
- if (IS_ERR(pcdev->clk_emma_ipg)) {
+ if (IS_ERR(pcdev->clk_emma_ahb))
return PTR_ERR(pcdev->clk_emma_ahb);
- }

irq_emma = platform_get_irq(pdev, 0);
res_emma = platform_get_resource(pdev, IORESOURCE_MEM, 0);

2012-08-25 19:57:26

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 3/6] drivers/usb/gadget/lpc32xx_udc.c: adjust inconsistent IS_ERR and PTR_ERR

From: Julia Lawall <[email protected]>

Change the call to PTR_ERR to access the value just tested by IS_ERR.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e,e1;
@@

(
if (IS_ERR(e)) { ... PTR_ERR(e) ... }
|
if (IS_ERR(e=e1)) { ... PTR_ERR(e) ... }
|
*if (IS_ERR(e))
{ ...
* PTR_ERR(e1)
... }
)
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/usb/gadget/lpc32xx_udc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/lpc32xx_udc.c b/drivers/usb/gadget/lpc32xx_udc.c
index f1ec99e..3a6cdd0 100644
--- a/drivers/usb/gadget/lpc32xx_udc.c
+++ b/drivers/usb/gadget/lpc32xx_udc.c
@@ -3208,7 +3208,7 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev)
udc->usb_otg_clk = clk_get(&pdev->dev, "ck_usb_otg");
if (IS_ERR(udc->usb_otg_clk)) {
dev_err(udc->dev, "failed to acquire USB otg clock\n");
- retval = PTR_ERR(udc->usb_slv_clk);
+ retval = PTR_ERR(udc->usb_otg_clk);
goto usb_otg_clk_get_fail;
}

2012-08-25 19:57:23

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 1/6] fs/nfsd/nfs4idmap.c: adjust inconsistent IS_ERR and PTR_ERR

From: Julia Lawall <[email protected]>

Change the call to PTR_ERR to access the value just tested by IS_ERR.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e,e1;
@@

(
if (IS_ERR(e)) { ... PTR_ERR(e) ... }
|
if (IS_ERR(e=e1)) { ... PTR_ERR(e) ... }
|
*if (IS_ERR(e))
{ ...
* PTR_ERR(e1)
... }
)
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>

---
fs/nfsd/nfs4idmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
index fdc91a6..11df4ac 100644
--- a/fs/nfsd/nfs4idmap.c
+++ b/fs/nfsd/nfs4idmap.c
@@ -478,7 +478,7 @@ nfsd_idmap_init(struct net *net)
goto destroy_idtoname_cache;
nn->nametoid_cache = cache_create_net(&nametoid_cache_template, net);
if (IS_ERR(nn->nametoid_cache)) {
- rv = PTR_ERR(nn->idtoname_cache);
+ rv = PTR_ERR(nn->nametoid_cache);
goto unregister_idtoname_cache;
}
rv = cache_register_net(nn->nametoid_cache, net);

2012-08-25 19:57:22

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 6/6] drivers/iio/adc/at91_adc.c: adjust inconsistent IS_ERR and PTR_ERR

From: Julia Lawall <[email protected]>

Change the call to PTR_ERR to access the value just tested by IS_ERR.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e,e1;
@@

(
if (IS_ERR(e)) { ... PTR_ERR(e) ... }
|
if (IS_ERR(e=e1)) { ... PTR_ERR(e) ... }
|
*if (IS_ERR(e))
{ ...
* PTR_ERR(e1)
... }
)
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/iio/adc/at91_adc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 98c96f9..8650281 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -604,7 +604,7 @@ static int __devinit at91_adc_probe(struct platform_device *pdev)
st->adc_clk = devm_clk_get(&pdev->dev, "adc_op_clk");
if (IS_ERR(st->adc_clk)) {
dev_err(&pdev->dev, "Failed to get the ADC clock.\n");
- ret = PTR_ERR(st->clk);
+ ret = PTR_ERR(st->adc_clk);
goto error_disable_clk;
}

2012-08-25 19:57:19

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 5/6] drivers/staging/crystalhd/crystalhd_lnx.c: adjust inconsistent IS_ERR and PTR_ERR

From: Julia Lawall <[email protected]>

Change the call to PTR_ERR to access the value just tested by IS_ERR.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e,e1;
@@

(
if (IS_ERR(e)) { ... PTR_ERR(e) ... }
|
if (IS_ERR(e=e1)) { ... PTR_ERR(e) ... }
|
*if (IS_ERR(e))
{ ...
* PTR_ERR(e1)
... }
)
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/staging/crystalhd/crystalhd_lnx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/crystalhd/crystalhd_lnx.c b/drivers/staging/crystalhd/crystalhd_lnx.c
index 5909d8d..166203a 100644
--- a/drivers/staging/crystalhd/crystalhd_lnx.c
+++ b/drivers/staging/crystalhd/crystalhd_lnx.c
@@ -381,7 +381,7 @@ static int __devinit chd_dec_init_chdev(struct crystalhd_adp *adp)
dev = device_create(crystalhd_class, NULL, MKDEV(adp->chd_dec_major, 0),
NULL, "crystalhd");
if (IS_ERR(dev)) {
- rc = PTR_ERR(crystalhd_class);
+ rc = PTR_ERR(dev);
BCMLOG_ERR("failed to create device\n");
goto device_create_fail;
}

2012-08-27 14:39:01

by Alan Stern

[permalink] [raw]
Subject: Re: [PATCH 4/6] drivers/usb/host/ohci-nxp.c: adjust inconsistent IS_ERR and PTR_ERR

On Sat, 25 Aug 2012, Julia Lawall wrote:

> From: Julia Lawall <[email protected]>
>
> Change the call to PTR_ERR to access the value just tested by IS_ERR.

> Signed-off-by: Julia Lawall <[email protected]>
>
> ---
> drivers/usb/host/ohci-nxp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/ohci-nxp.c b/drivers/usb/host/ohci-nxp.c
> index a446386..c60066a 100644
> --- a/drivers/usb/host/ohci-nxp.c
> +++ b/drivers/usb/host/ohci-nxp.c
> @@ -355,7 +355,7 @@ static int __devinit usb_hcd_nxp_probe(struct platform_device *pdev)
> usb_otg_clk = clk_get(&pdev->dev, "ck_usb_otg");
> if (IS_ERR(usb_otg_clk)) {
> dev_err(&pdev->dev, "failed to acquire USB DEV Clock\n");
> - ret = PTR_ERR(usb_dev_clk);
> + ret = PTR_ERR(usb_otg_clk);
> goto out6;
> }

Acked-by: Alan Stern <[email protected]>

2012-08-27 20:16:51

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH 6/6] drivers/iio/adc/at91_adc.c: adjust inconsistent IS_ERR and PTR_ERR

On 08/25/2012 08:57 PM, Julia Lawall wrote:
> From: Julia Lawall <[email protected]>
>
> Change the call to PTR_ERR to access the value just tested by IS_ERR.
>
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression e,e1;
> @@
>
> (
> if (IS_ERR(e)) { ... PTR_ERR(e) ... }
> |
> if (IS_ERR(e=e1)) { ... PTR_ERR(e) ... }
> |
> *if (IS_ERR(e))
> { ...
> * PTR_ERR(e1)
> ... }
> )
> // </smpl>
>
> Signed-off-by: Julia Lawall <[email protected]>
Thanks Julia and keep up the good work!

I've merge this one with a bit of fuzz to
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git

fixes-togreg
>
> ---
> drivers/iio/adc/at91_adc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> index 98c96f9..8650281 100644
> --- a/drivers/iio/adc/at91_adc.c
> +++ b/drivers/iio/adc/at91_adc.c
> @@ -604,7 +604,7 @@ static int __devinit at91_adc_probe(struct platform_device *pdev)
> st->adc_clk = devm_clk_get(&pdev->dev, "adc_op_clk");
> if (IS_ERR(st->adc_clk)) {
> dev_err(&pdev->dev, "Failed to get the ADC clock.\n");
> - ret = PTR_ERR(st->clk);
> + ret = PTR_ERR(st->adc_clk);
> goto error_disable_clk;
> }
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

2012-08-28 01:44:45

by J. Bruce Fields

[permalink] [raw]
Subject: Re: [PATCH 1/6] fs/nfsd/nfs4idmap.c: adjust inconsistent IS_ERR and PTR_ERR

On Sat, Aug 25, 2012 at 09:57:04PM +0200, Julia Lawall wrote:
> From: Julia Lawall <[email protected]>
>
> Change the call to PTR_ERR to access the value just tested by IS_ERR.

Applying for 3.7, thanks.--b.

>
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression e,e1;
> @@
>
> (
> if (IS_ERR(e)) { ... PTR_ERR(e) ... }
> |
> if (IS_ERR(e=e1)) { ... PTR_ERR(e) ... }
> |
> *if (IS_ERR(e))
> { ...
> * PTR_ERR(e1)
> ... }
> )
> // </smpl>
>
> Signed-off-by: Julia Lawall <[email protected]>
>
> ---
> fs/nfsd/nfs4idmap.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
> index fdc91a6..11df4ac 100644
> --- a/fs/nfsd/nfs4idmap.c
> +++ b/fs/nfsd/nfs4idmap.c
> @@ -478,7 +478,7 @@ nfsd_idmap_init(struct net *net)
> goto destroy_idtoname_cache;
> nn->nametoid_cache = cache_create_net(&nametoid_cache_template, net);
> if (IS_ERR(nn->nametoid_cache)) {
> - rv = PTR_ERR(nn->idtoname_cache);
> + rv = PTR_ERR(nn->nametoid_cache);
> goto unregister_idtoname_cache;
> }
> rv = cache_register_net(nn->nametoid_cache, net);
>