Skip to content

Commit 1dd473f

Browse files
OGAWAHirofumiJoel Becker
authored andcommitted
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: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Signed-off-by: Joel Becker <joel.becker@oracle.com>
1 parent 1b4d40a commit 1dd473f

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎fs/ocfs2/symlink.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,20 @@ static void *ocfs2_fast_follow_link(struct dentry *dentry,
137137
}
138138

139139
memcpy(link, target, len);
140-
nd_set_link(nd, link);
141140

142141
bail:
142+
nd_set_link(nd, status ? ERR_PTR(status) : link);
143143
brelse(bh);
144144

145145
mlog_exit(status);
146-
return status ? ERR_PTR(status) : link;
146+
return NULL;
147147
}
148148

149149
static void ocfs2_fast_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
150150
{
151-
char *link = cookie;
152-
153-
kfree(link);
151+
char *link = nd_get_link(nd);
152+
if (!IS_ERR(link))
153+
kfree(link);
154154
}
155155

156156
const struct inode_operations ocfs2_symlink_inode_operations = {

0 commit comments

Comments
 (0)