Commit 1dd473fd authored by OGAWA Hirofumi's avatar OGAWA Hirofumi Committed by Joel Becker

ocfs2: Fix refcnt leak on ocfs2_fast_follow_link() error path

If ->follow_link handler returns an error, it should decrement
nd->path refcnt. But ocfs2_fast_follow_link() doesn't decrement.

This patch fixes the problem by using nd_set_link() style error handling
instead of playing with nd->path.
Signed-off-by: default avatarOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: default avatarJoel Becker <joel.becker@oracle.com>
parent 1b4d40a5
...@@ -137,20 +137,20 @@ static void *ocfs2_fast_follow_link(struct dentry *dentry, ...@@ -137,20 +137,20 @@ static void *ocfs2_fast_follow_link(struct dentry *dentry,
} }
memcpy(link, target, len); memcpy(link, target, len);
nd_set_link(nd, link);
bail: bail:
nd_set_link(nd, status ? ERR_PTR(status) : link);
brelse(bh); brelse(bh);
mlog_exit(status); mlog_exit(status);
return status ? ERR_PTR(status) : link; return NULL;
} }
static void ocfs2_fast_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) static void ocfs2_fast_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
{ {
char *link = cookie; char *link = nd_get_link(nd);
if (!IS_ERR(link))
kfree(link); kfree(link);
} }
const struct inode_operations ocfs2_symlink_inode_operations = { const struct inode_operations ocfs2_symlink_inode_operations = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment