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>
This commit is contained in:
Al Viro
2016-05-12 19:35:57 -04:00
父節點 1d1bb236bc
當前提交 e82c314755
共有 3 個文件被更改,包括 14 次插入6 次删除

查看文件

@@ -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;