dfu: avoid memory leak
PATCH 1/1 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.
"
--- drivers/dfu/dfu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/dfu/dfu.c +3 -1
@@ -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++;
Signature · 1 line
2.6.2
PATCH 1/1 dfu: avoid memory leak
Quoted 9 lines · Peng Fan
When
dfu_fill_entityfail, 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.
"
Quoted 3 lines
Signed-off-by Peng Fan <[email protected]>Cc "?ukasz Majewski" <[email protected]>Cc Marek Vasut <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160503/cbfe7f09/attachment.sig>
PATCH 1/1 dfu: avoid memory leak
In reply to Peng FanHi Peng,
Quoted 22 lines
When
dfu_fill_entityfail, 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 <[email protected]>Cc "?ukasz Majewski" <[email protected]>Cc Marek Vasut <[email protected]>--- drivers/dfu/dfu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/dfu/dfu.c +0
-0@@ -468,8 +468,10 @@ int dfu_config_entities(char *env, char *interface, char *devstr) s = strsep(&env, ";");
drivers/dfu/dfu.c int dfu_config_entities(char *env, char · line 477
Quoted 10 lines
drivers/dfu/dfu.c +3
-1ret =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++;
Applied to u-boot-dfu tree.
Tested-at: Odroid U3 (Exynos4412)
Thanks for running coverity.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group