Messages in this thread | | | Date | Sun, 26 Jul 2009 17:32:13 +0800 | Subject | Re: [PATCH] lib/kobject: put kobject if kobject_add_internal fails | From | Ming Lei <> |
| |
2009/7/25 Xiaotian Feng <xtfeng@gmail.com>: > > > On Sat, Jul 25, 2009 at 2:52 PM, Ming Lei <tom.leiming@gmail.com> 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
| |