mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Rolf Eike Beer <eike-kernel@sf-tec.de>
Cc: linux-kernel@vger.kernel.org, "Chen,
	Kenneth W" <kenneth.w.chen@intel.com>
Subject: Re: [PATCH][CHAR] Return better error codes if drivers/char/raw.c module init fails
Date: Fri, 18 Aug 2006 16:27:43 -0700	[thread overview]
Message-ID: <20060818162743.f97ff431.akpm@osdl.org> (raw)
In-Reply-To: <200608180918.30483.eike-kernel@sf-tec.de>

On Fri, 18 Aug 2006 09:18:30 +0200
Rolf Eike Beer <eike-kernel@sf-tec.de> wrote:

> Currently this module just returns 1 if anything on module init fails. Store
> the error code of the different function calls and return their error on
> problems.
> 
> I'm not sure if this doesn't need even more cleanup, for example kobj_put() 
> is called only in one error case.
> 

You seem to be using kmail in funky-confuse-sylpheed mode.  Inlined patches
in plain-text emails are preferred, please.  

> 
> diff --git a/drivers/char/raw.c b/drivers/char/raw.c
> index 579868a..5938e6b 100644
> --- a/drivers/char/raw.c
> +++ b/drivers/char/raw.c
> @@ -288,31 +288,35 @@ static struct cdev raw_cdev = {
>  static int __init raw_init(void)
>  {
>  	dev_t dev = MKDEV(RAW_MAJOR, 0);
> +	int ret;
>  
> -	if (register_chrdev_region(dev, MAX_RAW_MINORS, "raw"))
> +	ret = register_chrdev_region(dev, MAX_RAW_MINORS, "raw");
> +	if (ret)
>  		goto error;
>  
>  	cdev_init(&raw_cdev, &raw_fops);
> -	if (cdev_add(&raw_cdev, dev, MAX_RAW_MINORS)) {
> +	ret = cdev_add(&raw_cdev, dev, MAX_RAW_MINORS); 
> +	if (ret) {
> +		printk(KERN_ERR "error register raw device\n");
>  		kobject_put(&raw_cdev.kobj);
> -		unregister_chrdev_region(dev, MAX_RAW_MINORS);
> -		goto error;
> +		goto error_region;
>  	}
>  
>  	raw_class = class_create(THIS_MODULE, "raw");
>  	if (IS_ERR(raw_class)) {
>  		printk(KERN_ERR "Error creating raw class.\n");
>  		cdev_del(&raw_cdev);
> -		unregister_chrdev_region(dev, MAX_RAW_MINORS);
> -		goto error;
> +		ret = PTR_ERR(raw_class);
> +		goto error_region;
>  	}
>  	class_device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl");
>  
>  	return 0;
>  
> +error_region:
> +	unregister_chrdev_region(dev, MAX_RAW_MINORS);
>  error:
> -	printk(KERN_ERR "error register raw device\n");
> -	return 1;
> +	return ret;
>  }

No, it's not obvious what that stray kobject_put() is doing in there.

<hunt, hunt>

http://kernel.org/git/?p=linux/kernel/git/torvalds/old-2.6-bkcvs.git;a=commitdiff;h=b8ff72d28c349bdb7ff5246e83aba384f45d8078



  reply	other threads:[~2006-08-18 23:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-18  7:18 Rolf Eike Beer
2006-08-18 23:27 ` Andrew Morton [this message]
2006-08-18 23:37   ` Randy.Dunlap
2006-08-20 15:22   ` Rolf Eike Beer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060818162743.f97ff431.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=eike-kernel@sf-tec.de \
    --cc=kenneth.w.chen@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome