diff options
author | Peng Fan <van.freenix@gmail.com> | 2016-05-03 10:24:52 +0800 |
---|---|---|
committer | Peng Fan <peng.fan@nxp.com> | 2016-07-01 16:00:44 +0800 |
commit | 9c2069ad87a068ba9bfde13a1a4026702edbe11a (patch) | |
tree | 619708d2732dd90005e6cbb53154786744ec2c14 | |
parent | 91703d0672342145da32d4e1bc1f42436dbae6cf (diff) | |
download | u-boot-imx-9c2069ad87a068ba9bfde13a1a4026702edbe11a.zip u-boot-imx-9c2069ad87a068ba9bfde13a1a4026702edbe11a.tar.gz u-boot-imx-9c2069ad87a068ba9bfde13a1a4026702edbe11a.tar.bz2 |
dfu: avoid memory leak
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@gmail.com>
Cc: "Ćukasz Majewski" <l.majewski@samsung.com>
Cc: Marek Vasut <marex@denx.de>
(cherry picked from commit 5d8fae79163e94671956c99654abf48cf49757ba)
-rw-r--r-- | drivers/dfu/dfu.c | 4 |
1 files changed, 3 insertions, 1 deletions
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++; |