diff options
| author | Dmitry Torokhov <dtor_core@ameritech.net> | 2004-07-08 02:46:10 -0700 |
|---|---|---|
| committer | Greg Kroah-Hartman <greg@kroah.com> | 2004-07-08 02:46:10 -0700 |
| commit | 4e12ac0f127911a024dbd15671a9073c23a0b312 (patch) | |
| tree | 57752a9e0901c6325d94a55ca40da1c8dd011bc3 /lib/kobject.c | |
| parent | 8f855b02474fd4c03a56db194a185265ba471c90 (diff) | |
[PATCH] Driver core: kset_find_obj should increment refcount of the found object
kset_find_obj should increment refcount of the found object so users of
the function can safely use returned object
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'lib/kobject.c')
| -rw-r--r-- | lib/kobject.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/kobject.c b/lib/kobject.c index bcf4a9be0dcd..781f3e896695 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -537,7 +537,8 @@ void kset_unregister(struct kset * k) * @name: object's name. * * Lock kset via @kset->subsys, and iterate over @kset->list, - * looking for a matching kobject. Return object if found. + * looking for a matching kobject. If matching object is found + * take a reference and return the object. */ struct kobject * kset_find_obj(struct kset * kset, const char * name) @@ -548,8 +549,8 @@ struct kobject * kset_find_obj(struct kset * kset, const char * name) down_read(&kset->subsys->rwsem); list_for_each(entry,&kset->list) { struct kobject * k = to_kobj(entry); - if (kobject_name(k) && (!strcmp(kobject_name(k),name))) { - ret = k; + if (kobject_name(k) && !strcmp(kobject_name(k),name)) { + ret = kobject_get(k); break; } } |
