[U-Boot] [PATCH] dfu: avoid memory leak
Lukasz Majewski
l.majewski at samsung.com
Fri May 6 11:10:18 CEST 2016
Hi Peng,
> When dfu_fill_entity fail, need to free dfu to avoid memory leak.
>
> Reported by Coverity:
> "
> Resource leak (RESOURCE_LEAK)
> leaked_storage: Variable dfu going out of scope leaks the storage
> it points to.
> "
>
> Signed-off-by: Peng Fan <van.freenix at gmail.com>
> Cc: "Łukasz Majewski" <l.majewski at samsung.com>
> Cc: Marek Vasut <marex at denx.de>
> ---
> drivers/dfu/dfu.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
> index 8f5915e..20dfcbb 100644
> --- a/drivers/dfu/dfu.c
> +++ b/drivers/dfu/dfu.c
> @@ -468,8 +468,10 @@ int dfu_config_entities(char *env, char
> *interface, char *devstr) s = strsep(&env, ";");
> ret = dfu_fill_entity(&dfu[i], s, alt_num_cnt,
> interface, devstr);
> - if (ret)
> + if (ret) {
> + free(dfu);
> return -1;
> + }
>
> list_add_tail(&dfu[i].list, &dfu_list);
> alt_num_cnt++;
Acked-by: Lukasz Majewski <l.majewski at samsung.com>
Applied to u-boot-dfu tree.
Tested-at: Odroid U3 (Exynos4412)
Thanks for running coverity.
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
More information about the U-Boot
mailing list