Skip to content

Commit

Permalink
ocfs2: Fix refcnt leak on ocfs2_fast_follow_link() error path
Browse files Browse the repository at this point in the history
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: OGAWA Hirofumi <[email protected]>
Signed-off-by: Joel Becker <[email protected]>
  • Loading branch information
OGAWAHirofumi authored and Joel Becker committed Jan 11, 2010
1 parent 1b4d40a commit 1dd473f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions fs/ocfs2/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,20 @@ static void *ocfs2_fast_follow_link(struct dentry *dentry,
}

memcpy(link, target, len);
nd_set_link(nd, link);

bail:
nd_set_link(nd, status ? ERR_PTR(status) : link);
brelse(bh);

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)
{
char *link = cookie;

kfree(link);
char *link = nd_get_link(nd);
if (!IS_ERR(link))
kfree(link);
}

const struct inode_operations ocfs2_symlink_inode_operations = {
Expand Down

0 comments on commit 1dd473f

Please sign in to comment.