* [patch] can: c_can: checking IS_ERR() instead of NULL
@ 2014-08-01 8:53 Dan Carpenter
2014-08-01 9:01 ` Marc Kleine-Budde
2014-08-01 18:16 ` Wolfram Sang
0 siblings, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2014-08-01 8:53 UTC (permalink / raw)
To: Wolfgang Grandegger, George Cherian
Cc: Marc Kleine-Budde, Grant Likely, Rob Herring, Thor Thayer,
Pavel Machek, Mugunthan V N, Lad, Prabhakar, Wolfram Sang,
linux-can, kernel-janitors
devm_ioremap() returns NULL on error, not an ERR_PTR().
Fixes: 33cf75656923 ('can: c_can_platform: Fix raminit, use devm_ioremap() instead of devm_ioremap_resource()')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This will need to go to -stable because the patch which introduces the
bug is going to be pushed to -stable.
diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
index 5dede6e..109cb44 100644
--- a/drivers/net/can/c_can/c_can_platform.c
+++ b/drivers/net/can/c_can/c_can_platform.c
@@ -280,7 +280,7 @@ static int c_can_plat_probe(struct platform_device *pdev)
priv->raminit_ctrlreg = devm_ioremap(&pdev->dev, res->start,
resource_size(res));
- if (IS_ERR(priv->raminit_ctrlreg) || priv->instance < 0)
+ if (!priv->raminit_ctrlreg || priv->instance < 0)
dev_info(&pdev->dev, "control memory is not used for raminit\n");
else
priv->raminit = c_can_hw_raminit_ti;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [patch] can: c_can: checking IS_ERR() instead of NULL
2014-08-01 8:53 [patch] can: c_can: checking IS_ERR() instead of NULL Dan Carpenter
@ 2014-08-01 9:01 ` Marc Kleine-Budde
2014-08-01 9:13 ` Dan Carpenter
2014-08-01 18:16 ` Wolfram Sang
1 sibling, 1 reply; 5+ messages in thread
From: Marc Kleine-Budde @ 2014-08-01 9:01 UTC (permalink / raw)
To: Dan Carpenter, Wolfgang Grandegger, George Cherian
Cc: Grant Likely, Rob Herring, Thor Thayer, Pavel Machek,
Mugunthan V N, Lad, Prabhakar, Wolfram Sang, linux-can,
kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1410 bytes --]
On 08/01/2014 10:53 AM, Dan Carpenter wrote:
> devm_ioremap() returns NULL on error, not an ERR_PTR().
>
> Fixes: 33cf75656923 ('can: c_can_platform: Fix raminit, use devm_ioremap() instead of devm_ioremap_resource()')
Doh!
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> This will need to go to -stable because the patch which introduces the
> bug is going to be pushed to -stable.
>
> diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
> index 5dede6e..109cb44 100644
> --- a/drivers/net/can/c_can/c_can_platform.c
> +++ b/drivers/net/can/c_can/c_can_platform.c
> @@ -280,7 +280,7 @@ static int c_can_plat_probe(struct platform_device *pdev)
>
> priv->raminit_ctrlreg = devm_ioremap(&pdev->dev, res->start,
> resource_size(res));
> - if (IS_ERR(priv->raminit_ctrlreg) || priv->instance < 0)
> + if (!priv->raminit_ctrlreg || priv->instance < 0)
What about using PTR_ERR_OR_ZERO()?
> dev_info(&pdev->dev, "control memory is not used for raminit\n");
> else
> priv->raminit = c_can_hw_raminit_ti;
>
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: 242 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] can: c_can: checking IS_ERR() instead of NULL
2014-08-01 9:01 ` Marc Kleine-Budde
@ 2014-08-01 9:13 ` Dan Carpenter
2014-08-01 9:15 ` Marc Kleine-Budde
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2014-08-01 9:13 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: Wolfgang Grandegger, George Cherian, Grant Likely, Rob Herring,
Thor Thayer, Pavel Machek, Mugunthan V N, Lad, Prabhakar,
Wolfram Sang, linux-can, kernel-janitors
On Fri, Aug 01, 2014 at 11:01:36AM +0200, Marc Kleine-Budde wrote:
> > diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
> > index 5dede6e..109cb44 100644
> > --- a/drivers/net/can/c_can/c_can_platform.c
> > +++ b/drivers/net/can/c_can/c_can_platform.c
> > @@ -280,7 +280,7 @@ static int c_can_plat_probe(struct platform_device *pdev)
> >
> > priv->raminit_ctrlreg = devm_ioremap(&pdev->dev, res->start,
> > resource_size(res));
> > - if (IS_ERR(priv->raminit_ctrlreg) || priv->instance < 0)
> > + if (!priv->raminit_ctrlreg || priv->instance < 0)
>
> What about using PTR_ERR_OR_ZERO()?
No. It doesn't ever return a PTR_ERR(). Checking for that would just
introduce a new static checker warning (signs of confusion may indicate
buggy code).
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] can: c_can: checking IS_ERR() instead of NULL
2014-08-01 9:13 ` Dan Carpenter
@ 2014-08-01 9:15 ` Marc Kleine-Budde
0 siblings, 0 replies; 5+ messages in thread
From: Marc Kleine-Budde @ 2014-08-01 9:15 UTC (permalink / raw)
To: Dan Carpenter
Cc: Wolfgang Grandegger, George Cherian, Grant Likely, Rob Herring,
Thor Thayer, Pavel Machek, Mugunthan V N, Lad, Prabhakar,
Wolfram Sang, linux-can, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1210 bytes --]
On 08/01/2014 11:13 AM, Dan Carpenter wrote:
> On Fri, Aug 01, 2014 at 11:01:36AM +0200, Marc Kleine-Budde wrote:
>
>>> diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
>>> index 5dede6e..109cb44 100644
>>> --- a/drivers/net/can/c_can/c_can_platform.c
>>> +++ b/drivers/net/can/c_can/c_can_platform.c
>>> @@ -280,7 +280,7 @@ static int c_can_plat_probe(struct platform_device *pdev)
>>>
>>> priv->raminit_ctrlreg = devm_ioremap(&pdev->dev, res->start,
>>> resource_size(res));
>>> - if (IS_ERR(priv->raminit_ctrlreg) || priv->instance < 0)
>>> + if (!priv->raminit_ctrlreg || priv->instance < 0)
>>
>> What about using PTR_ERR_OR_ZERO()?
>
> No. It doesn't ever return a PTR_ERR(). Checking for that would just
> introduce a new static checker warning (signs of confusion may indicate
> buggy code).
Okay, thanks for the clarification.
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: 242 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] can: c_can: checking IS_ERR() instead of NULL
2014-08-01 8:53 [patch] can: c_can: checking IS_ERR() instead of NULL Dan Carpenter
2014-08-01 9:01 ` Marc Kleine-Budde
@ 2014-08-01 18:16 ` Wolfram Sang
1 sibling, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2014-08-01 18:16 UTC (permalink / raw)
To: Dan Carpenter, Wolfgang Grandegger, George Cherian
Cc: Marc Kleine-Budde, Grant Likely, Rob Herring, Thor Thayer,
Pavel Machek, Mugunthan V N, Lad, Prabhakar, linux-can,
kernel-janitors
> Fixes: 33cf75656923 ('can: c_can_platform: Fix raminit, use devm_ioremap() instead of devm_ioremap_resource()')
Reverting this patch is the correct solution. Its approach is totally
bogus anyhow.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-08-01 18:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-01 8:53 [patch] can: c_can: checking IS_ERR() instead of NULL Dan Carpenter
2014-08-01 9:01 ` Marc Kleine-Budde
2014-08-01 9:13 ` Dan Carpenter
2014-08-01 9:15 ` Marc Kleine-Budde
2014-08-01 18:16 ` Wolfram Sang
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).