From: Andrew Morton <akpm@linux-foundation.org>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linux-kernel@vger.kernel.org, greg@kroah.com,
Kay Sievers <kay.sievers@vrfy.org>, Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH] devres: WARN() and return, don't crash on device_del() of uninitialized device
Date: Tue, 26 May 2009 14:15:52 -0700 [thread overview]
Message-ID: <20090526141552.507f8821.akpm@linux-foundation.org> (raw)
In-Reply-To: <20090525065346.1D991DE2AC@ozlabs.org>
On Mon, 25 May 2009 16:53:31 +1000
Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> I just debugged an obscure crash caused by a device_del() of a all NULL'd
> out struct device (in usb-serial) and found that a patch like this one would
> have saved me time (in addition to improved chances of a bug report from
> users hitting similar driver bugs).
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
>
> drivers/base/devres.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> --- linux-work.orig/drivers/base/devres.c 2009-05-25 16:43:46.000000000 +1000
> +++ linux-work/drivers/base/devres.c 2009-05-25 16:46:36.000000000 +1000
> @@ -428,6 +428,11 @@ int devres_release_all(struct device *de
> {
> unsigned long flags;
>
> + /* Looks like an uninitialized device structure */
> + if (dev->devres_head.next == NULL) {
> + WARN(1);
> + return -ENODEV;
> + }
> spin_lock_irqsave(&dev->devres_lock, flags);
> return release_nodes(dev, dev->devres_head.next, &dev->devres_head,
> flags);
This could be coded a little more neatly as:
/* Looks like an uninitialized device structure */
if (WARN_ON(dev->devres_head.next == NULL))
return -ENODEV;
next prev parent reply other threads:[~2009-05-26 21:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-25 6:53 Benjamin Herrenschmidt
2009-05-26 21:15 ` Andrew Morton [this message]
2009-05-26 22:23 ` Benjamin Herrenschmidt
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=20090526141552.507f8821.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=greg@kroah.com \
--cc=kay.sievers@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@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