Re: [PATCH] drivers: base: core: do not put noninitialized devices

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Vasiliy Kulikov
Date: Friday, November 19, 2010 - 12:14 pm

Hi Greg,

On Fri, Nov 19, 2010 at 11:02 -0800, Greg KH wrote:

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);


int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
				  va_list vargs)
{
    [...]
	kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
	if (!kobj->name)
		return -ENOMEM;


char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
{
    [...]
	p = kmalloc(len+1, gfp);
	if (!p)
		return NULL;

Unlikely, but may fail in OOM situation.


Thanks,

-- 
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] drivers: base: core: do not put noninitialized ..., Vasiliy Kulikov, (Fri Nov 19, 12:14 pm)