[PATCH] Linux 2.6.0-test5 OOPS in sysfs

From: Ranjeet Shetye
Date: Wed Sep 17 2003 - 19:07:09 EST



A week back I ran into this bug which was causing an OOPS. Andrew Morton
sent me a fix which worked and which I acknowledged on the mailing list
as being the correct fix. However I haven't seen this fix make its way
into the code, so I am sending it again.

Please note that the bug was fixed by Andrew, not me.

thanks,
--

Ranjeet Shetye
Senior Software Engineer
Zultys Technologies
Ranjeet dot Shetye2 at Zultys dot com
http://www.zultys.com/

The views, opinions, and judgements expressed in this message are solely
those of the author. The message contents have not been reviewed or
approved by Zultys.

Index: fs/sysfs/dir.c
===================================================================
RCS file: /home/cvs/linux-2.5/fs/sysfs/dir.c,v
retrieving revision 1.8
diff -d -u -r1.8 dir.c
--- fs/sysfs/dir.c 5 Sep 2003 21:17:55 -0000 1.8
+++ fs/sysfs/dir.c 17 Sep 2003 22:15:21 -0000
@@ -24,10 +24,11 @@
static struct dentry *
create_dir(struct kobject * k, struct dentry * p, const char * n)
{
- struct dentry * dentry;
+ struct dentry * dentry, * ret;

down(&p->d_inode->i_sem);
dentry = sysfs_get_dentry(p,n);
+ ret = dentry;
if (!IS_ERR(dentry)) {
int error = sysfs_create(dentry,
S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO,
@@ -36,11 +37,11 @@
dentry->d_fsdata = k;
p->d_inode->i_nlink++;
} else
- dentry = ERR_PTR(error);
+ ret = ERR_PTR(error);
dput(dentry);
}
up(&p->d_inode->i_sem);
- return dentry;
+ return ret;
}