Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH] c2port: fix device_create() return value check

1 view
Skip to first unread message

Jani Nikula

unread,
Mar 11, 2010, 11:30:02 AM3/11/10
to
From: Jani Nikula <ext-jani...@nokia.com>

Use IS_ERR() instead of comparing to NULL.

Signed-off-by: Jani Nikula <ext-jani...@nokia.com>

---

NOTE: I'm afraid I'm unable to test this; please consider this more a
bug report than a complete patch.
---
drivers/misc/c2port/core.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
index b5346b4..3276216 100644
--- a/drivers/misc/c2port/core.c
+++ b/drivers/misc/c2port/core.c
@@ -912,7 +912,7 @@ struct c2port_device *c2port_device_register(char *name,

c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
"c2port%d", id);
- if (unlikely(!c2dev->dev)) {
+ if (unlikely(IS_ERR(c2dev->dev))) {
ret = -ENOMEM;
goto error_device_create;
}
--
1.6.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Andrew Morton

unread,
Mar 15, 2010, 6:20:03 PM3/15/10
to
On Thu, 11 Mar 2010 18:20:52 +0200
Jani Nikula <ext-jani...@nokia.com> wrote:

> From: Jani Nikula <ext-jani...@nokia.com>
>
> Use IS_ERR() instead of comparing to NULL.
>
> Signed-off-by: Jani Nikula <ext-jani...@nokia.com>
>
> ---
>
> NOTE: I'm afraid I'm unable to test this; please consider this more a
> bug report than a complete patch.
> ---
> drivers/misc/c2port/core.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
> index b5346b4..3276216 100644
> --- a/drivers/misc/c2port/core.c
> +++ b/drivers/misc/c2port/core.c
> @@ -912,7 +912,7 @@ struct c2port_device *c2port_device_register(char *name,
>
> c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
> "c2port%d", id);
> - if (unlikely(!c2dev->dev)) {
> + if (unlikely(IS_ERR(c2dev->dev))) {
> ret = -ENOMEM;
> goto error_device_create;
> }

It looks right to me. Let's finish the job:

--- a/drivers/misc/c2port/core.c~c2port-fix-device_create-return-value-check-fix
+++ a/drivers/misc/c2port/core.c
@@ -913,7 +913,7 @@ struct c2port_device *c2port_device_regi


c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
"c2port%d", id);

if (unlikely(IS_ERR(c2dev->dev))) {
- ret = -ENOMEM;
+ ret = PTR_ERR(c2dev->dev);
goto error_device_create;
}
dev_set_drvdata(c2dev->dev, c2dev);
_

0 new messages