diff options
| author | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2010-01-11 13:37:45 -0500 |
|---|---|---|
| committer | Joel Becker <joel.becker@oracle.com> | 2010-01-11 18:38:50 -0500 |
| commit | 1dd473fdf1d8a7531e0955480cd129f9c1e8b8a3 (patch) | |
| tree | bed53c5c5f93dc61ef074b5fcebc6bc86dc6e99b | |
| parent | 1b4d40a517e0657a081d5d63518c4badd31c60ea (diff) | |
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>
| -rw-r--r-- | fs/ocfs2/symlink.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c index 49b133ccbf11..32499d213fc4 100644 --- a/fs/ocfs2/symlink.c +++ b/fs/ocfs2/symlink.c | |||
| @@ -137,20 +137,20 @@ static void *ocfs2_fast_follow_link(struct dentry *dentry, | |||
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | memcpy(link, target, len); | 139 | memcpy(link, target, len); |
| 140 | nd_set_link(nd, link); | ||
| 141 | 140 | ||
| 142 | bail: | 141 | bail: |
| 142 | nd_set_link(nd, status ? ERR_PTR(status) : link); | ||
| 143 | brelse(bh); | 143 | brelse(bh); |
| 144 | 144 | ||
| 145 | mlog_exit(status); | 145 | mlog_exit(status); |
| 146 | return status ? ERR_PTR(status) : link; | 146 | return NULL; |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | static void ocfs2_fast_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) | 149 | static void ocfs2_fast_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) |
| 150 | { | 150 | { |
| 151 | char *link = cookie; | 151 | char *link = nd_get_link(nd); |
| 152 | 152 | if (!IS_ERR(link)) | |
| 153 | kfree(link); | 153 | kfree(link); |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | const struct inode_operations ocfs2_symlink_inode_operations = { | 156 | const struct inode_operations ocfs2_symlink_inode_operations = { |
