2006-09-12 01:19:22

by Alexey Dobriyan

[permalink] [raw]
Subject: [PATCH] raw: return negative from raw_init()

Signed-off-by: Alexey Dobriyan <[email protected]>
---

drivers/char/raw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -312,7 +312,7 @@ static int __init raw_init(void)

error:
printk(KERN_ERR "error register raw device\n");
- return 1;
+ return -1;
}

static void __exit raw_exit(void)


2006-09-12 03:34:23

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] raw: return negative from raw_init()

On Monday 11 September 2006 21:19, Alexey Dobriyan wrote:
> Signed-off-by: Alexey Dobriyan <[email protected]>
> ---
>
> drivers/char/raw.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/drivers/char/raw.c
> +++ b/drivers/char/raw.c
> @@ -312,7 +312,7 @@ static int __init raw_init(void)
>
> error:
> printk(KERN_ERR "error register raw device\n");
> - return 1;
> + return -1;
> }
>

How about reworking it a bit to pass true error code from the failed
call? Additionally class_device_create call is not checked for errors
there.

--
Dmitry

2006-09-14 21:31:23

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] raw: return negative from raw_init()

On Tue, 12 Sep 2006 05:19:18 +0400
Alexey Dobriyan <[email protected]> wrote:

> Signed-off-by: Alexey Dobriyan <[email protected]>
> ---
>
> drivers/char/raw.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/drivers/char/raw.c
> +++ b/drivers/char/raw.c
> @@ -312,7 +312,7 @@ static int __init raw_init(void)
>
> error:
> printk(KERN_ERR "error register raw device\n");
> - return 1;
> + return -1;
> }
>
> static void __exit raw_exit(void)

Rolf got there first. Please review
ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.18-rc6/2.6.18-rc6-mm2/broken-out/return-better-error-codes-if-drivers-char-rawc-module-init-fails.patch