]> git.sur5r.net Git - u-boot/commitdiff
ext4: fix leak in check_filename()
authorStephen Warren <swarren@nvidia.com>
Sat, 5 Sep 2015 04:03:45 +0000 (22:03 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 11 Sep 2015 21:15:23 +0000 (17:15 -0400)
root_first_block_buffer should be free()d in all cases, not just when an
error occurs. Fix the success exit path of the function to do this.

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_common.c

index 9fdbfe6e2db5f8738b2f154f169333e0babd7efc..410419e241bc64f9709e0008bfbb3382eb029c74 100644 (file)
@@ -770,6 +770,7 @@ static int check_filename(char *filename, unsigned int blknr)
        struct ext2_dirent *previous_dir = NULL;
        char *ptr = NULL;
        struct ext_filesystem *fs = get_fs();
+       int ret = -1;
 
        /* get the first block of root */
        first_block_no_of_root = blknr;
@@ -823,12 +824,12 @@ static int check_filename(char *filename, unsigned int blknr)
                if (ext4fs_put_metadata(root_first_block_addr,
                                        first_block_no_of_root))
                        goto fail;
-               return inodeno;
+               ret = inodeno;
        }
 fail:
        free(root_first_block_buffer);
 
-       return -1;
+       return ret;
 }
 
 int ext4fs_filename_check(char *filename)