Re: [PATCH] lib/kobject: put kobject if kobject_add_internal fails

From: Ming Lei
Date: Sun Jul 26 2009 - 05:37:50 EST


2009/7/25 Xiaotian Feng <xtfeng@xxxxxxxxx>:
>
>
> On Sat, Jul 25, 2009 at 2:52 PM, Ming Lei <tom.leiming@xxxxxxxxx> wrote:
>> Even you can make sure _all_ .release of the passed kobj_type does not
>> free
>> the kobject, you still have the double calling of kobject_put problem,
>> don't you?
>
>
> hmm, how about change kobject_put to kfree(kobj->name) ? Then it's safe for
> both cases, right?

No, it is very buggy and ugly to kfree kobj->name directly by kobject
users instead
of kobject_put(). Image that someone uses the kobject after kfree(kobj->name)
but before kobject_put, oops may happen.

Why don't you fix the 20+ callers of kobject_init_and_add? It is the
standard way of doing
such thing.

--
Lei Ming
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/