diff options
author | Tejun Heo <tj@kernel.org> | 2014-02-10 17:57:09 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-02-10 19:00:19 -0500 |
commit | 9561a8961c708ff6ba3e71a817af0f16bdc1d885 (patch) | |
tree | 6a9d3c7b3175c81dcc0a053569f1a3707bc0ddbb /fs/kernfs | |
parent | ba341d55a420ab4fdd1a53fd395fd59bd65de880 (diff) |
kernfs: fix hash calculation in kernfs_rename_ns()
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>
Diffstat (limited to 'fs/kernfs')
-rw-r--r-- | fs/kernfs/dir.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index a347792c2e5a..a0f99b7f84b2 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c | |||
@@ -1295,7 +1295,7 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent, | |||
1295 | 1295 | ||
1296 | spin_unlock_irq(&kernfs_rename_lock); | 1296 | spin_unlock_irq(&kernfs_rename_lock); |
1297 | 1297 | ||
1298 | kn->hash = kernfs_name_hash(new_name, new_ns); | 1298 | kn->hash = kernfs_name_hash(kn->name, kn->ns); |
1299 | kernfs_link_sibling(kn); | 1299 | kernfs_link_sibling(kn); |
1300 | 1300 | ||
1301 | kernfs_put(old_parent); | 1301 | kernfs_put(old_parent); |