From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/3] dfu: Fix memory leak in dfu_init_env_entities()
Date: Fri, 13 Jul 2018 11:42:01 +0200 [thread overview]
Message-ID: <20180713114201.546a6bc2@jawa> (raw)
In-Reply-To: <20180712215253.4290-2-semen.protsenko@linaro.org>
Hi Sam,
> In case of error in dfu_init_env_entities(), env_bkp will leak. Fix it
> by providing single return path.
>
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> ---
> drivers/dfu/dfu.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
> index a3c09334b7..5b9abd685d 100644
> --- a/drivers/dfu/dfu.c
> +++ b/drivers/dfu/dfu.c
> @@ -56,7 +56,7 @@ int dfu_init_env_entities(char *interface, char
> *devstr) {
> const char *str_env;
> char *env_bkp;
> - int ret;
> + int ret = 0;
>
> #ifdef CONFIG_SET_DFU_ALT_INFO
> set_dfu_alt_info(interface, devstr);
> @@ -71,11 +71,12 @@ int dfu_init_env_entities(char *interface, char
> *devstr) ret = dfu_config_entities(env_bkp, interface, devstr);
> if (ret) {
> pr_err("DFU entities configuration failed!\n");
> - return ret;
> + goto done;
> }
>
> +done:
> free(env_bkp);
> - return 0;
> + return ret;
> }
>
> static unsigned char *dfu_buf;
Acked-by: Lukasz Majewski <lukma@denx.de>
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180713/dc3f619d/attachment.sig>
next prev parent reply other threads:[~2018-07-13 9:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-12 21:52 [U-Boot] [PATCH 1/3] dfu: Fix data abort in dfu_free_entities() Sam Protsenko
2018-07-12 21:52 ` [U-Boot] [PATCH 2/3] dfu: Fix memory leak in dfu_init_env_entities() Sam Protsenko
2018-07-13 9:42 ` Lukasz Majewski [this message]
2018-07-12 21:52 ` [U-Boot] [PATCH 3/3] dfu: Provide more verbose error message Sam Protsenko
2018-07-13 9:43 ` Lukasz Majewski
2018-07-12 22:10 ` [U-Boot] [PATCH 1/3] dfu: Fix data abort in dfu_free_entities() Sam Protsenko
2018-07-13 2:32 ` Andy Shevchenko
2018-07-13 13:18 ` Sam Protsenko
2018-07-13 9:49 ` Lukasz Majewski
2018-07-13 13:28 ` Sam Protsenko
2018-07-13 9:41 ` Lukasz Majewski
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=20180713114201.546a6bc2@jawa \
--to=lukma@denx.de \
--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