[PATCH v2 22/28] fs/squashfs: sqfs_close/sqfs_read_sblk: set ctxt.sblk to NULL after free
Richard Genoud
richard.genoud at posteo.net
Tue Nov 3 12:11:20 CET 2020
This will prevent a double free error if sqfs_close() is called twice.
Signed-off-by: Richard Genoud <richard.genoud at posteo.net>
---
fs/squashfs/sqfs.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c
index 7d6f0e88e31..a46e19c75c5 100644
--- a/fs/squashfs/sqfs.c
+++ b/fs/squashfs/sqfs.c
@@ -49,6 +49,7 @@ static int sqfs_read_sblk(struct squashfs_super_block **sblk)
if (sqfs_disk_read(0, 1, *sblk) != 1) {
free(*sblk);
+ sblk = NULL;
return -EINVAL;
}
@@ -1638,6 +1639,7 @@ free_strings:
void sqfs_close(void)
{
free(ctxt.sblk);
+ ctxt.sblk = NULL;
ctxt.cur_dev = NULL;
sqfs_decompressor_cleanup(&ctxt);
}
More information about the U-Boot
mailing list