sysfs: Allow sysfs_move_dir(..., NULL) again.
authorCornelia Huck <cornelia.huck@de.ibm.com>
Tue, 6 Oct 2009 13:33:35 +0000 (15:33 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 14 Oct 2009 22:16:25 +0000 (15:16 -0700)
As device_move() and kobject_move() both handle a NULL destination,
sysfs_move_dir() should do this as well (again) and fall back to
sysfs_root in that case.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Phil Carmody <ext-phil.2.carmody@nokia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/sysfs/dir.c

index 0050fc40e8c9f373a3f7c61855870ad7d4a1952c..5fad489ce5bcde2ab514e3108f112cd5de005f17 100644 (file)
@@ -894,7 +894,8 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj)
 
        mutex_lock(&sysfs_rename_mutex);
        BUG_ON(!sd->s_parent);
-       new_parent_sd = new_parent_kobj->sd ? new_parent_kobj->sd : &sysfs_root;
+       new_parent_sd = (new_parent_kobj && new_parent_kobj->sd) ?
+               new_parent_kobj->sd : &sysfs_root;
 
        error = 0;
        if (sd->s_parent == new_parent_sd)