[PATCH] back out sysfs reference count change

From: Greg KH
Date: Tue Mar 30 2004 - 18:58:40 EST


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.


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 @@
if (!error) {
- (*d)->d_op = &sysfs_dentry_operations;
- (*d)->d_fsdata = kobject_get(k);
+ (*d)->d_fsdata = k;
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/