]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fs/squashfs: sqfs_read: fix memory leak
authorRichard Genoud <richard.genoud@posteo.net>
Tue, 3 Nov 2020 11:11:13 +0000 (12:11 +0100)
committerTom Rini <trini@konsulko.com>
Thu, 19 Nov 2020 14:45:49 +0000 (09:45 -0500)
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>
fs/squashfs/sqfs.c

index 1ac07625889ef6074a932a23c288ffe5479feb03..a9e803cbac2afb1fb613263596da0256ff93307a 100644 (file)
@@ -1341,7 +1341,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;
        }
@@ -1532,6 +1531,7 @@ free_datablk:
 free_paths:
        free(file);
        free(dir);
+       sqfs_closedir(dirsp);
 
        return ret;
 }