]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ext4: avoid calling ext4fs_mount() twice, which leaks
authorStephen Warren <swarren@nvidia.com>
Sat, 5 Sep 2015 04:03:43 +0000 (22:03 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 11 Sep 2015 21:15:22 +0000 (17:15 -0400)
ext4_write_file() is only called from the "fs" layer, which calls both
ext4fs_mount() and ext4fs_close() before/after calling ext4_write_file().
Fix ext4_write_file() not to call ext4fs_mount() again, since the mount
operation malloc()s some RAM which is leaked when a second mount call
over-writes the pointer to that data, if no intervening close call is
made.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Lukasz Majewski <l.majewski@samsung.com>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>
fs/ext4/ext4_write.c

index d346c065cd8a75e7f9dc3d1440b6aad951b50ebf..e027916763f9b52937c7fe13f1698b67b94eb901 100644 (file)
@@ -987,26 +987,17 @@ int ext4_write_file(const char *filename, void *buf, loff_t offset,
                return -1;
        }
 
-       /* mount the filesystem */
-       if (!ext4fs_mount(0)) {
-               printf("** Error Bad ext4 partition **\n");
-               goto fail;
-       }
-
        ret = ext4fs_write(filename, buf, len);
-
        if (ret) {
                printf("** Error ext4fs_write() **\n");
                goto fail;
        }
-       ext4fs_close();
 
        *actwrite = len;
 
        return 0;
 
 fail:
-       ext4fs_close();
        *actwrite = 0;
 
        return -1;