public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Nikanth Karthikesan <knikanth@suse.de>
Cc: axboe@kernel.dk, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Fix error handling in add_disk
Date: Wed, 24 Jun 2009 20:11:54 -0700	[thread overview]
Message-ID: <20090624201154.7e89cbee.akpm@linux-foundation.org> (raw)
In-Reply-To: <200906241218.13538.knikanth@suse.de>

On Wed, 24 Jun 2009 12:18:13 +0530 Nikanth Karthikesan <knikanth@suse.de> wrote:

> On Wednesday 24 June 2009 02:53:57 Andrew Morton wrote:
> > On Wed, 17 Jun 2009 12:31:10 +0530
> >
> > Nikanth Karthikesan <knikanth@suse.de> wrote:
> > > Fix error handling in add_disk. Also add WARN_ON()'s in case
> > > of error, which can be removed once the callers handle the error.
> >
> > I have a vague ancestral memory that some of the unchecked errors which
> > you're now checking for actually do happen in practice, and that this
> > "fix" will end up breaking currently-working setups.
> >
> > Or maybe I'm thinking of a similar but different piece of code (maybe
> > it was the partition code?).
> >
> > Still, I think it would be prudent to initially make this patch
> > continue to ignore the errors.  So add the warnings, but don't change
> > the response to errors.  Then we can get the change distributed for a
> > bit of testing and if that all looks good then we can add the control
> > flow changes later.
> >
> 
> add_disk and blk_register_region are functions returning void masking the
> error

ugh, we're bad.

> which this patch changes. So no caller check for it's return value! And
> hence errors are ignored, and nothing breaks.

It _does_ change behaviour.  add_disk() can now bale out if, for
example, sysfs_create_link() failed.  As it commonly does, due to
various screwups.

> > >  	retval = blk_alloc_devt(&disk->part0, &devt);
> > >  	if (retval) {
> > >  		WARN_ON(1);
> > > -		return;
> > > +		goto err_out;
> > >  	}
> > > ...
> > > +	if (retval) {
> > > +		WARN_ON(1);
> > > +		goto err_free_devt;
> > > +	}
> > > ...
> > > +	if (retval) {
> > > +		WARN_ON(1);
> > > +		goto err_free_region;
> > > +	}
> > > ...
> > > -	WARN_ON(retval);
> > > +	if (retval) {
> > > +		WARN_ON(1);
> > > +		goto err_free_queue;
> > > +	}
> >
> > These all can be coded as
> >
> > 	if (WARN_ON(retval))
> > 		goto foo;
> 
> done.
> 
> Thanks
> Nikanth
> 
> 
> Fix error handling in add_disk. Also add WARN_ON()'s in case
> of error, which can be removed once the callers handle the error.

The changelog hasn't been updated to reflect this discussion.  There's
information missing here.


Also, why was this patch written?  Have you observed some behaviour
which this patch improved or corrected?

I applaud the effort, but it's obviously incomplete.  Do you intend to
add further error checking and handling in this area?

  reply	other threads:[~2009-06-25  3:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-17  7:01 [PATCH] Fix error handling in add_disk Nikanth Karthikesan
2009-06-23 21:23 ` Andrew Morton
2009-06-24  6:48   ` Nikanth Karthikesan
2009-06-25  3:11     ` Andrew Morton [this message]
2009-06-25 10:17       ` Nikanth Karthikesan

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=20090624201154.7e89cbee.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=knikanth@suse.de \
    --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