From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 03/10] ext4: free allocations by parse_path()
Date: Tue, 08 Sep 2015 15:10:16 +0200 [thread overview]
Message-ID: <20150908151016.482e2cad@amdc2363> (raw)
In-Reply-To: <1441425831-3441-3-git-send-email-swarren@wwwdotorg.org>
Hi Stephen,
> From: Stephen Warren <swarren@nvidia.com>
>
> 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>
> ---
> fs/ext4/ext4_common.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
> index cab5465b9d4f..b09f23aa5b83 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);
Acked-by: Lukasz Majewski <l.majewski@samsung.com>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>
Test HW: Odroid XU3 - Exynos5433
[DFU tests]
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
next prev parent reply other threads:[~2015-09-08 13:10 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-05 4:03 [U-Boot] [PATCH 01/10] usb: gadget: don't leak configs when unbinding Stephen Warren
2015-09-05 4:03 ` [U-Boot] [PATCH 02/10] ext4: avoid calling ext4fs_mount() twice, which leaks Stephen Warren
2015-09-08 13:22 ` Lukasz Majewski
2015-09-12 12:51 ` [U-Boot] [U-Boot, " Tom Rini
2015-09-05 4:03 ` [U-Boot] [PATCH 03/10] ext4: free allocations by parse_path() Stephen Warren
2015-09-08 13:10 ` Lukasz Majewski [this message]
2015-09-12 12:51 ` [U-Boot] [U-Boot,03/10] " Tom Rini
2015-09-05 4:03 ` [U-Boot] [PATCH 04/10] ext4: fix leak in check_filename() Stephen Warren
2015-09-08 13:05 ` Lukasz Majewski
2015-09-12 12:51 ` [U-Boot] [U-Boot,04/10] " Tom Rini
2015-09-05 4:03 ` [U-Boot] [PATCH 05/10] dfu: don't keep freeing/reallocating Stephen Warren
2015-09-08 12:32 ` Lukasz Majewski
2015-09-12 12:51 ` [U-Boot] [U-Boot,05/10] " Tom Rini
2015-09-05 4:03 ` [U-Boot] [PATCH 06/10] dfu: mmc: buffer file reads too Stephen Warren
2015-09-08 12:57 ` Lukasz Majewski
2015-09-12 12:51 ` [U-Boot] [U-Boot,06/10] " Tom Rini
2015-09-05 4:03 ` [U-Boot] [PATCH 07/10] ARM: tegra: fix malloc region sizing Stephen Warren
2015-09-08 16:53 ` Tom Warren
2015-09-08 21:45 ` Stephen Warren
2015-09-08 21:52 ` Stephen Warren
2015-09-08 21:56 ` Tom Rini
2015-09-08 21:56 ` Stephen Warren
2015-09-09 6:51 ` Lukasz Majewski
2015-09-09 16:08 ` Tom Warren
2015-09-12 12:51 ` [U-Boot] [U-Boot,07/10] " Tom Rini
2015-09-05 4:03 ` [U-Boot] [PATCH 08/10] ARM: tegra: tweak DFU buffer sizes Stephen Warren
2015-09-12 12:51 ` [U-Boot] [U-Boot,08/10] " Tom Rini
2015-09-05 4:03 ` [U-Boot] [PATCH 09/10] ARM: tegra: enable filesystem writing Stephen Warren
2015-09-12 12:51 ` [U-Boot] [U-Boot,09/10] " Tom Rini
2015-09-05 4:03 ` [U-Boot] [PATCH 10/10] ARM: tegra: enable DFU for RAM Stephen Warren
2015-09-12 12:51 ` [U-Boot] [U-Boot,10/10] " Tom Rini
2015-09-08 12:00 ` [U-Boot] [PATCH 01/10] usb: gadget: don't leak configs when unbinding Lukasz Majewski
2015-09-08 21:50 ` Stephen Warren
2015-09-12 12:51 ` [U-Boot] [U-Boot, " Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150908151016.482e2cad@amdc2363 \
--to=l.majewski@samsung.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox