diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c index 8ba8c4c50770..0a586a7f470e 100644 --- a/fs/squashfs/file.c +++ b/fs/squashfs/file.c @@ -547,6 +547,9 @@ static void squashfs_readahead(struct readahead_control *ractl) int i, file_end = i_size_read(inode) >> msblk->block_log; unsigned int max_pages = 1UL << shift; + if (!file_end && !start) + return; + readahead_expand(ractl, start, (len | mask) + 1); pages = kmalloc_array(max_pages, sizeof(void *), GFP_KERNEL); diff --git a/fs/squashfs/file_direct.c b/fs/squashfs/file_direct.c index f1ccad519e28..9c167df9248d 100644 --- a/fs/squashfs/file_direct.c +++ b/fs/squashfs/file_direct.c @@ -35,6 +35,9 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize, struct squashfs_page_actor *actor; void *pageaddr; + if (!file_end) + return -EINVAL; + if (end_index > file_end) end_index = file_end;