From: Richard Genoud Date: Tue, 24 Nov 2020 17:07:52 +0000 (+0100) Subject: fs/squashfs: sqfs_close/sqfs_read_sblk: set ctxt.sblk to NULL after free X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=165ba02bff83a1710303cdbbc47ca7a95cae0ebc;p=platform%2Fkernel%2Fu-boot.git fs/squashfs: sqfs_close/sqfs_read_sblk: set ctxt.sblk to NULL after free This will prevent a double free error if sqfs_close() is called twice. Signed-off-by: Richard Genoud [jh80.chung: cherry picked from mainline commit 7e932ac790b3615a67a3c24041c194aa748c0d98] Signed-off-by: Jaehoon Chung Change-Id: I31166f8f9d6ec6d4772e7b51b5d0bb8d20ef1a4b --- diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c index 8064756939..4e11727c7f 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; } @@ -1692,9 +1693,10 @@ free_strings: void sqfs_close(void) { + sqfs_decompressor_cleanup(&ctxt); free(ctxt.sblk); + ctxt.sblk = NULL; ctxt.cur_dev = NULL; - sqfs_decompressor_cleanup(&ctxt); } void sqfs_closedir(struct fs_dir_stream *dirs)