From: Greg KH <gregkh@suse.de>
To: Vasiliy Kulikov <segoon@openwall.com>
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers: base: core: do not put noninitialized devices
Date: Fri, 19 Nov 2010 20:57:09 +0000 [thread overview]
Message-ID: <20101119205709.GA17531@suse.de> (raw)
In-Reply-To: <20101119191424.GA12273@albatros>
On Fri, Nov 19, 2010 at 10:14:25PM +0300, Vasiliy Kulikov wrote:
> Hi Greg,
>
> On Fri, Nov 19, 2010 at 11:02 -0800, Greg KH wrote:
> > On Fri, Nov 19, 2010 at 09:41:40PM +0300, Vasiliy Kulikov wrote:
> > > If kobject_set_name_vargs() fails then put_device() frees
> > > device with zero kobj->state_initialized. This leads to WARN().
> >
> > Have you seen this happen?
>
> No, I've just analized the code. Without device_initialize() ->kobj is
> not initialized:
>
> kobject_init(&dev->kobj, &device_ktype) calls
>
> kobject_init_internal(kobj) calls
>
> kobj->state_initialized = 1;
>
> kobject_put() calls WARN if state_initialized = 0:
>
> void kobject_put(struct kobject *kobj)
> {
> if (kobj) {
> if (!kobj->state_initialized)
> WARN(1, KERN_WARNING "kobject: '%s' (%p): is not "
> "initialized, yet kobject_put() is being "
> "called.\n", kobject_name(kobj), kobj);
>
>
> I got the stack dump with similar code:
>
> struct device *dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> put_device(dev);
Sure, that's illegal code, and we want to warn about that. So I would
say, if an error happens, we want to see this message so the code should
stay as-is.
thanks,
greg k-h
next prev parent reply other threads:[~2010-11-19 20:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-19 18:41 [PATCH] drivers: base: core: do not put noninitialized devices Vasiliy Kulikov
2010-11-19 19:02 ` Greg KH
2010-11-19 19:14 ` Vasiliy Kulikov
2010-11-19 19:17 ` Vasiliy Kulikov
2010-11-19 20:57 ` Greg KH [this message]
2010-11-20 9:00 ` Vasiliy Kulikov
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=20101119205709.GA17531@suse.de \
--to=gregkh@suse.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=segoon@openwall.com \
/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;
as well as URLs for NNTP newsgroup(s).