Skip to content

Commit d7147a3

Browse files
QGrainakpm00
authored andcommitted
squashfs: fix invalid pointer dereference in squashfs_cache_delete
When mounting a squashfs fails, squashfs_cache_init() may return an error pointer (e.g., -ENOMEM) instead of NULL. However, squashfs_cache_delete() only checks for a NULL cache, and attempts to dereference the invalid pointer. This leads to a kernel crash (BUG: unable to handle kernel paging request in squashfs_cache_delete). This patch fixes the issue by checking IS_ERR(cache) before accessing it. Link: https://lkml.kernel.org/r/[email protected] Fixes: 49ff292 ("squashfs: make squashfs_cache_init() return ERR_PTR(-ENOMEM)") Signed-off-by: Zhiyu Zhang <[email protected]> Reported-by: Zhiyu Zhang <[email protected]> Closes: https://lore.kernel.org/linux-fsdevel/CALf2hKvaq8B4u5yfrE+BYt7aNguao99mfWxHngA+=o5hwzjdOg@mail.gmail.com/ Tested-by: Zhiyu Zhang <[email protected]> Reviewed-by: Phillip Lougher <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 60cf233 commit d7147a3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/squashfs/cache.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void squashfs_cache_delete(struct squashfs_cache *cache)
198198
{
199199
int i, j;
200200

201-
if (cache == NULL)
201+
if (IS_ERR(cache) || cache == NULL)
202202
return;
203203

204204
for (i = 0; i < cache->entries; i++) {

0 commit comments

Comments
 (0)