提交 f71626a4 编写于 作者: L Latchesar Ionkov 提交者: Linus Torvalds

[PATCH] v9fs: don't free root dentry & inode if error occurs in v9fs_get_sb

If error occurs while in v9fs_get_sb after it calles sget, the dentry object
of the root and its inode may be freed twice -- once while handling the error
in v9fs_get_sb, and second time when v9fs_get_sb calles deactivate_super
(which in turn calls v9fs_kill_super)

The patch removes the unnecessary code that frees the root dentry and its
inode.
Signed-off-by: NLatchesar Ionkov <lucho@ionkov.net>
Cc: Eric Van Hensbergen <ericvh@gmail.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 a1f9d8d2
...@@ -129,8 +129,8 @@ static struct super_block *v9fs_get_sb(struct file_system_type ...@@ -129,8 +129,8 @@ static struct super_block *v9fs_get_sb(struct file_system_type
if ((newfid = v9fs_session_init(v9ses, dev_name, data)) < 0) { if ((newfid = v9fs_session_init(v9ses, dev_name, data)) < 0) {
dprintk(DEBUG_ERROR, "problem initiating session\n"); dprintk(DEBUG_ERROR, "problem initiating session\n");
retval = newfid; kfree(v9ses);
goto free_session; return ERR_PTR(newfid);
} }
sb = sget(fs_type, NULL, v9fs_set_super, v9ses); sb = sget(fs_type, NULL, v9fs_set_super, v9ses);
...@@ -150,7 +150,7 @@ static struct super_block *v9fs_get_sb(struct file_system_type ...@@ -150,7 +150,7 @@ static struct super_block *v9fs_get_sb(struct file_system_type
if (!root) { if (!root) {
retval = -ENOMEM; retval = -ENOMEM;
goto release_inode; goto put_back_sb;
} }
sb->s_root = root; sb->s_root = root;
...@@ -159,7 +159,7 @@ static struct super_block *v9fs_get_sb(struct file_system_type ...@@ -159,7 +159,7 @@ static struct super_block *v9fs_get_sb(struct file_system_type
root_fid = v9fs_fid_create(root); root_fid = v9fs_fid_create(root);
if (root_fid == NULL) { if (root_fid == NULL) {
retval = -ENOMEM; retval = -ENOMEM;
goto release_dentry; goto put_back_sb;
} }
root_fid->fidopen = 0; root_fid->fidopen = 0;
...@@ -182,25 +182,15 @@ static struct super_block *v9fs_get_sb(struct file_system_type ...@@ -182,25 +182,15 @@ static struct super_block *v9fs_get_sb(struct file_system_type
if (stat_result < 0) { if (stat_result < 0) {
retval = stat_result; retval = stat_result;
goto release_dentry; goto put_back_sb;
} }
return sb; return sb;
release_dentry: put_back_sb:
dput(sb->s_root); /* deactivate_super calls v9fs_kill_super which will frees the rest */
release_inode:
iput(inode);
put_back_sb:
up_write(&sb->s_umount); up_write(&sb->s_umount);
deactivate_super(sb); deactivate_super(sb);
v9fs_session_close(v9ses);
free_session:
kfree(v9ses);
return ERR_PTR(retval); return ERR_PTR(retval);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册