From 87a8ca985bc0b63f8ad166b648f54496e097101e Mon Sep 17 00:00:00 2001 From: Sam Protsenko Date: Fri, 13 Jul 2018 16:35:46 +0300 Subject: [PATCH] dfu: Fix memory leak in dfu_init_env_entities() 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 --- 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; -- 2.25.1