diff options
| author | Zhao Mengmeng <zhaomengmeng@kylinos.cn> | 2024-10-01 19:54:25 +0800 |
|---|---|---|
| committer | Jan Kara <jack@suse.cz> | 2024-10-02 14:32:29 +0200 |
| commit | c226964ec786f3797ed389a16392ce4357697d24 (patch) | |
| tree | add167e7ec4e9da31ed4ad4f8419900b815c6d01 /fs/udf/truncate.c | |
| parent | b405c1e58b73981da0f8df03b00666b22b9397ae (diff) | |
udf: refactor inode_bmap() to handle error
Refactor inode_bmap() to handle error since udf_next_aext() can return
error now. On situations like ftruncate, udf_extend_file() can now
detect errors and bail out early without resorting to checking for
particular offsets and assuming internal behavior of these functions.
Reported-by: syzbot+7a4842f0b1801230a989@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=7a4842f0b1801230a989
Tested-by: syzbot+7a4842f0b1801230a989@syzkaller.appspotmail.com
Signed-off-by: Zhao Mengmeng <zhaomengmeng@kylinos.cn>
Suggested-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20241001115425.266556-4-zhaomzhao@126.com
Diffstat (limited to 'fs/udf/truncate.c')
| -rw-r--r-- | fs/udf/truncate.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c index 399958f891d1..4f33a4a48886 100644 --- a/fs/udf/truncate.c +++ b/fs/udf/truncate.c @@ -214,10 +214,12 @@ int udf_truncate_extents(struct inode *inode) else BUG(); - etype = inode_bmap(inode, first_block, &epos, &eloc, &elen, &offset); + ret = inode_bmap(inode, first_block, &epos, &eloc, &elen, &offset, &etype); + if (ret < 0) + return ret; byte_offset = (offset << sb->s_blocksize_bits) + (inode->i_size & (sb->s_blocksize - 1)); - if (etype == -1) { + if (ret == 0) { /* We should extend the file? */ WARN_ON(byte_offset); return 0; |