Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=cfb36fff45e3997b8044c81045fc4869ba5f281a
Commit:     cfb36fff45e3997b8044c81045fc4869ba5f281a
Parent:     d76e15fb20eeb7632ef38876a884fe3508b2c01d
Author:     Greg Kroah-Hartman <[EMAIL PROTECTED]>
AuthorDate: Wed Nov 28 10:46:22 2007 -0800
Committer:  Greg Kroah-Hartman <[EMAIL PROTECTED]>
CommitDate: Thu Jan 24 20:40:25 2008 -0800

    kobject: grab the kset reference in kobject_add, not kobject_init
    
    kobject_init should not be grabing any references, but only initializing
    the object.  This patch fixes this, and makes the lock hold-time shorter
    for when a kset is present in the kobject.
    
    The current kernel tree has been audited to verify that this change
    should be safe.
    
    Cc: Kay Sievers <[EMAIL PROTECTED]>
    Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
---
 lib/kobject.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/kobject.c b/lib/kobject.c
index 7919c32..4d52b6f 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -133,7 +133,6 @@ void kobject_init(struct kobject * kobj)
                return;
        kref_init(&kobj->kref);
        INIT_LIST_HEAD(&kobj->entry);
-       kobj->kset = kset_get(kobj->kset);
 }
 
 
@@ -184,7 +183,7 @@ int kobject_add(struct kobject * kobj)
                 kobj->kset ? kobject_name(&kobj->kset->kobj) : "<NULL>" );
 
        if (kobj->kset) {
-               spin_lock(&kobj->kset->list_lock);
+               kobj->kset = kset_get(kobj->kset);
 
                if (!parent) {
                        parent = kobject_get(&kobj->kset->kobj);
@@ -196,7 +195,8 @@ int kobject_add(struct kobject * kobj)
                        kobject_get(parent);
                }
 
-               list_add_tail(&kobj->entry,&kobj->kset->list);
+               spin_lock(&kobj->kset->list_lock);
+               list_add_tail(&kobj->entry, &kobj->kset->list);
                spin_unlock(&kobj->kset->list_lock);
                kobj->parent = parent;
        }
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to