Skip to content

Commit

Permalink
sysfs: Fix oops in sysfs_drop_dentry on x86_64
Browse files Browse the repository at this point in the history
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 <rjw@sisk.pl>
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Rafael J. Wysocki authored and Greg Kroah-Hartman committed Jul 11, 2007
1 parent 0c73f18 commit 9d9307d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/sysfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void sysfs_drop_dentry(struct sysfs_dirent *sd)
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)
Expand All @@ -295,6 +295,7 @@ int sysfs_hash_and_remove(struct dentry * dir, const char * name)
/* 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;
Expand Down

0 comments on commit 9d9307d

Please sign in to comment.