fs/squashfs: sqfs_read: fix memory leak 77/250877/1
authorRichard Genoud <richard.genoud@posteo.net>
Tue, 3 Nov 2020 11:11:13 +0000 (12:11 +0100)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 5 Jan 2021 07:09:14 +0000 (16:09 +0900)
sqfs_closedir() should be called to free memory allocated by
sqfs_opendir()

Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com>
Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
[jh80.chung: cherry picked from mainline commit 7ce9745cbeae7733a7068f19a7fc3ec8f21dc38c]
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Change-Id: I200f764bb6ce2bb828e2217d1b0f949e1db14597

fs/squashfs/sqfs.c

index 8e2863ac0243c261fc0405f1be6aa4b56f23f75b..a71ada06601036f85fdb32be61d89aafaf03ac5c 100644 (file)
@@ -1344,7 +1344,6 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len,
        if (ret) {
                printf("File not found.\n");
                *actread = 0;
-               sqfs_closedir(dirsp);
                ret = -ENOENT;
                goto free_paths;
        }
@@ -1535,6 +1534,7 @@ free_datablk:
 free_paths:
        free(file);
        free(dir);
+       sqfs_closedir(dirsp);
 
        return ret;
 }