[PATCH] back out sysfs reference count change

Greg KH
2004-03-30T23:56:40Z

Hi,

The patch below backs out Maneesh's sysfs patch that was recently added
to the kernel. In its defense, the original patch did solve some fixes
that could be duplicated on SMP machines, but the side affect of the
patch caused lots of problems. Basically it caused kobjects to get
their references incremented when files that are not present in the
kobject are asked for (udev can easily trigger this when it looks for
files call "dev" in directories that do not have that file). This can
cause easy oopses when the VFS later ages out those old dentries and the
kobject has its reference finally released (usually after the module
that the kobject lived in was removed.)

I will continue to work with Maneesh to try to solve the original bug,
but for now, this patch needs to be applied.

thanks,

greg k-h

--- 1.10/fs/sysfs/dir.c Fri Mar 19 17:46:51 2004
+++ edited/fs/sysfs/dir.c Tue Mar 30 15:23:21 2004
@@ -20,18 +20,6 @@
return 0;
}

-static void sysfs_d_iput(struct dentry * dentry, struct inode * inode)
-{
- struct kobject * kobj = dentry->d_fsdata;
-
- if (kobj)
- kobject_put(kobj);
- iput(inode);
-}
-
-static struct dentry_operations sysfs_dentry_operations = {
- .d_iput = &sysfs_d_iput,
-};

static int create_dir(struct kobject * k, struct dentry * p,
const char * n, struct dentry ** d)
@@ -45,8 +33,7 @@
S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO,
init_dir);
if (!error) {
- (*d)->d_op = &sysfs_dentry_operations;
- (*d)->d_fsdata = kobject_get(k);
+ (*d)->d_fsdata = k;
p->d_inode->i_nlink++;
}
dput(*d);