summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2015-09-04 22:03:44 -0600
committerDongjin Kim <tobetter@gmail.com>2020-02-10 22:44:41 +0900
commitc1118c53cbe94ee461b85c7f593bd1952b16d189 (patch)
tree34ce0c27e57441a62553891d648f72717beb34f9
parent6830b129c23cd872c2be81327750f75679004bf4 (diff)
downloadu-boot-odroid-c1-c1118c53cbe94ee461b85c7f593bd1952b16d189.tar.gz
ext4: free allocations by parse_path()
parse_path() malloc()s the entries in the array it's passed. Those allocations must be free()d by the caller, ext4fs_get_parent_inode_num(). Add code to do this. For this to work, all the array entries must be dynamically allocated, rather than a mix of dynamic and static allocations. Fix parse_path() not to over-write arr[0] with a pointer to statically allocated data. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Lukasz Majewski <l.majewski@samsung.com> Tested-by: Lukasz Majewski <l.majewski@samsung.com>
-rw-r--r--fs/ext4/ext4_common.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index ff10a84e96..0cbfd75566 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -614,8 +614,7 @@ static int parse_path(char **arr, char *dirname)
arr[i] = zalloc(strlen("/") + 1);
if (!arr[i])
return -ENOMEM;
-
- arr[i++] = "/";
+ memcpy(arr[i++], "/", strlen("/"));
/* add each path entry after root */
while (token != NULL) {
@@ -745,6 +744,11 @@ end:
fail:
free(depth_dirname);
free(parse_dirname);
+ for (i = 0; i < depth; i++) {
+ if (!ptr[i])
+ break;
+ free(ptr[i]);
+ }
free(ptr);
free(parent_inode);
free(first_inode);