]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Fix dentry refcounting in sysfs_remove_group()
authorAndrew Morton <akpm@osdl.org>
Thu, 18 Mar 2004 22:59:31 +0000 (14:59 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 18 Mar 2004 22:59:31 +0000 (14:59 -0800)
From: Maneesh Soni <maneesh@in.ibm.com>

The following patch fixes the dentry refcounting, during
sysfs_remove_group() and also adds the missing dput() for the "extra" ref
taken during sysfs_create() for the sub-directory dentry corresponding to
attribute group.

fs/sysfs/group.c

index 27eb52ec393592e5b47dd0ec79df54ffda79c453..61b2462f6e98a2c46161fe8362963d2c00d3a87e 100644 (file)
@@ -55,8 +55,8 @@ int sysfs_create_group(struct kobject * kobj,
        if ((error = create_files(dir,grp))) {
                if (grp->name)
                        sysfs_remove_subdir(dir);
-               dput(dir);
        }
+       dput(dir);
        return error;
 }
 
@@ -68,12 +68,13 @@ void sysfs_remove_group(struct kobject * kobj,
        if (grp->name)
                dir = sysfs_get_dentry(kobj->dentry,grp->name);
        else
-               dir = kobj->dentry;
+               dir = dget(kobj->dentry);
 
        remove_files(dir,grp);
-       dput(dir);
        if (grp->name)
                sysfs_remove_subdir(dir);
+       /* release the ref. taken in this routine */
+       dput(dir);
 }