diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-05-13 02:35:57 +0300 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-05-13 02:35:57 +0300 |
commit | e82c3147554785414a10a2d424590758646972b2 (patch) | |
tree | 54dcbe319a89601b153cfb8556faee1e6a6dda19 /fs/hpfs/dir.c | |
parent | 1d1bb236bc2ffb3586d6cc73e58c0d8351758123 (diff) | |
download | linux-e82c3147554785414a10a2d424590758646972b2.tar.xz |
hpfs: handle allocation failures in hpfs_add_pos()
pr_err() is nice, but we'd better propagate the error
to caller and not proceed to violate the invariants
(namely, "every file with f_pos tied to directory block
should have its address visible in per-inode array").
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/hpfs/dir.c')
-rw-r--r-- | fs/hpfs/dir.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c index e57a53c13d86..77b92ff56ce2 100644 --- a/fs/hpfs/dir.c +++ b/fs/hpfs/dir.c @@ -44,7 +44,11 @@ static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence) else goto fail; if (pos == 12) goto fail; } - hpfs_add_pos(i, &filp->f_pos); + if (unlikely(hpfs_add_pos(i, &filp->f_pos) < 0)) { + hpfs_unlock(s); + inode_unlock(i); + return -ENOMEM; + } ok: filp->f_pos = new_off; hpfs_unlock(s); @@ -141,8 +145,10 @@ static int hpfs_readdir(struct file *file, struct dir_context *ctx) ctx->pos = 1; } if (ctx->pos == 1) { + ret = hpfs_add_pos(inode, &file->f_pos); + if (unlikely(ret < 0)) + goto out; ctx->pos = ((loff_t) hpfs_de_as_down_as_possible(inode->i_sb, hpfs_inode->i_dno) << 4) + 1; - hpfs_add_pos(inode, &file->f_pos); file->f_version = inode->i_version; } next_pos = ctx->pos; |