From htejun@gmail.com Wed Jun 13 11:45:43 2007 From: Rafael J. Wysocki Cc: Tejun Heo , Rafael J. Wysocki Subject: [PATCH 31/31] sysfs: Fix oops in sysfs_drop_dentry on x86_64 Date: Thu, 14 Jun 2007 03:45:18 +0900 Message-Id: <1181760318135-git-send-email-htejun@gmail.com> To: greg@kroah.com, rjw@sisk.pl, akpm@linux-foundation.org, htejun@gmail.com From: Rafael J. Wysocki Fix oops on x86_64 caused by the dereference of dir in sysfs_drop_dentry() made before checking if dir is not NULL (cf. http://marc.info/?l=linux-kernel&m=118151626704924&w=2). Signed-off-by: Rafael J. Wysocki Signed-off-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman --- fs/sysfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/sysfs/inode.c +++ b/fs/sysfs/inode.c @@ -285,7 +285,7 @@ void sysfs_drop_dentry(struct sysfs_dire int sysfs_hash_and_remove(struct dentry * dir, const char * name) { struct sysfs_dirent **pos, *sd; - struct sysfs_dirent *parent_sd = dir->d_fsdata; + struct sysfs_dirent *parent_sd; int found = 0; if (!dir) @@ -295,6 +295,7 @@ int sysfs_hash_and_remove(struct dentry /* no inode means this hasn't been made visible yet */ return -ENOENT; + parent_sd = dir->d_fsdata; mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT); for (pos = &parent_sd->s_children; *pos; pos = &(*pos)->s_sibling) { sd = *pos;