]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kernfs: fix hash calculation in kernfs_rename_ns()
authorTejun Heo <tj@kernel.org>
Mon, 10 Feb 2014 22:57:09 +0000 (17:57 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Feb 2014 00:00:19 +0000 (16:00 -0800)
3eef34ad7dc3 ("kernfs: implement kernfs_get_parent(),
kernfs_name/path() and friends") restructured kernfs_rename_ns() such
that new name assignment happens under kernfs_rename_lock;
unfortunately, it mistakenly passed NULL to kernfs_name_hash() to
calculate the new hash if the name hasn't changed, which can lead to
oops.

Fix it by using kn->name and kn->ns when calculating the new hash.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Dan Carpenter dan.carpenter@oracle.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/kernfs/dir.c

index a347792c2e5a1b60e410433f1c392be21ae7ed67..a0f99b7f84b25386e3b533af219fd85f856e5ca2 100644 (file)
@@ -1295,7 +1295,7 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
 
        spin_unlock_irq(&kernfs_rename_lock);
 
-       kn->hash = kernfs_name_hash(new_name, new_ns);
+       kn->hash = kernfs_name_hash(kn->name, kn->ns);
        kernfs_link_sibling(kn);
 
        kernfs_put(old_parent);