From: Vasiliy Kulikov <segoon@openwall.com>
To: Greg KH <gregkh@suse.de>
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers: base: core: do not put noninitialized devices
Date: Sat, 20 Nov 2010 12:00:59 +0300 [thread overview]
Message-ID: <20101120090058.GA4263@albatros> (raw)
In-Reply-To: <20101119205709.GA17531@suse.de>
On Fri, Nov 19, 2010 at 12:57 -0800, Greg KH wrote:
> On Fri, Nov 19, 2010 at 10:14:25PM +0300, Vasiliy Kulikov wrote:
> > 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,
You might misunderstood me, see this part of device_create_vargs():
struct device *device_create_vargs(...)
{
...
dev = kzalloc(sizeof(*dev), GFP_KERNEL); <<<
if (!dev)
...
dev->devt = devt;
dev->class = class;
dev->parent = parent;
dev->release = device_create_release;
dev_set_drvdata(dev, drvdata);
retval = kobject_set_name_vargs(&dev->kobj, fmt, args); <<<
if (retval)
goto error; <<<
...
error:
put_device(dev); <<<
...
}
It is device_create_vargs()'s mistake, not the caller.
> 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.
If you mean "if memomy allocation for name fails then we want to see
message about allocation failure" then maybe use pr_err("No mem for device
name\n") instead of confusing "kobject is not initialized, yet kobject_put()
is being called"?
Thanks,
--
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments
prev parent reply other threads:[~2010-11-20 9:01 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
2010-11-20 9:00 ` Vasiliy Kulikov [this message]
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=20101120090058.GA4263@albatros \
--to=segoon@openwall.com \
--cc=gregkh@suse.de \
--cc=kernel-janitors@vger.kernel.org \
--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