From 5d8fae79163e94671956c99654abf48cf49757ba Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Tue, 3 May 2016 10:24:52 +0800 Subject: dfu: avoid memory leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Cc: "Ɓukasz Majewski" Cc: Marek Vasut --- drivers/dfu/dfu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/dfu/dfu.c') 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++; -- cgit v1.1