Skip to content

Commit e6b83b5

Browse files
hsiangkaojosephhz
authored andcommitted
anolis: erofs: fix unexpected endless loop when read < 0
ANBZ: torvalds#183 read is ssize_t (signed type) and size is u64. If read < 0, read < size will never be true. Reported-by: Liu Bo <[email protected]> Reviewed-by: Jeffle Xu <[email protected]> Reviewed-by: Liu Bo <[email protected]> Reviewed-by: Joseph Qi <[email protected]> Signed-off-by: Gao Xiang <[email protected]>
1 parent 013a1bd commit e6b83b5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/erofs/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,11 @@ static ssize_t rafs_v6_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
484484
inode->i_size, map.m_pa, delta, size);
485485
read = rafs_v6_read_chunk(inode->i_sb, to, map.m_pa + delta,
486486
size, map.m_deviceid);
487-
if (read < size) {
487+
if (read <= 0 || read < size) {
488488
erofs_err(inode->i_sb,
489489
"short read %ld pos %llu size %llu @ nid %llu",
490490
read, pos, size, EROFS_I(inode)->nid);
491-
return -EIO;
491+
return read < 0 ? read : -EIO;
492492
}
493493
iocb->ki_pos += read;
494494
bytes += read;

0 commit comments

Comments
 (0)