[PATCH] squashfs: free page if bio_add_page fails

From: Leon M. George
Date: Fri May 13 2022 - 07:06:21 EST


In squashfs_bio_read, the page recently allocated for use with
bio_add_page isn't freed when the call fails.

This patch adds a call to __free_page.

Signed-off-by: Leon M. George <leon@xxxxxxxxxxxxx>
---
fs/squashfs/block.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c
index 622c844f6d11..5ca1c9caef7d 100644
--- a/fs/squashfs/block.c
+++ b/fs/squashfs/block.c
@@ -110,6 +110,7 @@ static int squashfs_bio_read(struct super_block *sb, u64 index, int length,
}
if (!bio_add_page(bio, page, len, offset)) {
error = -EIO;
+ __free_page(page);
goto out_free_bio;
}
offset = 0;
--
2.35.1