Skip to contentSkip to conversation

dfu: free entities when parsing fails

PATCH New Stephen Warren 2 participants 2 messages Jun 10, 2014 – Jun 18, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dfu: free entities when parsing fails

From: Stephen Warren <[email protected]>

When dfu_init_env_entities() fails part-way through, some entities may have been added to dfu_list. These are only removed by dfu_free_entities(). If that function isn't called, those stale entities will still exist the next time dfu_init_env_entities() is called, leading to confusion. Fix do_dfu() to ensure that dfu_free_entities() is always called, to avoid this confusion.

---
 common/cmd_dfu.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
common/cmd_dfu.c +3 -2
index a03538dabb37..433bddd5d2bd 100644
@@ -27,8 +27,9 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	ret = dfu_init_env_entities(interface, simple_strtoul(devstring,
 							      NULL, 10));
 	if (ret)
-		return ret;
+		goto done;
 
+	ret = CMD_RET_SUCCESS;
 	if (argc > 4 && strcmp(argv[4], "list") == 0) {
 		dfu_show_entities();
 		goto done;
@@ -61,7 +62,7 @@ done:
 	if (dfu_reset())
 		run_command("reset", 0);
 
-	return CMD_RET_SUCCESS;
+	return ret;
 }
 
 U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
Signature · 1 line
1.8.1.5
#1 lore raw

PATCH 1/1 dfu: free entities when parsing fails

Hi Stephen,

Quoted 30 lines

From: Stephen Warren <[email protected]>

When dfu_init_env_entities() fails part-way through, some entities may have been added to dfu_list. These are only removed by dfu_free_entities(). If that function isn't called, those stale entities will still exist the next time dfu_init_env_entities() is called, leading to confusion. Fix do_dfu() to ensure that dfu_free_entities() is always called, to avoid this confusion.

---
 common/cmd_dfu.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
common/cmd_dfu.c +2 -1
index a03538dabb37..433bddd5d2bd 100644
@@ -27,8 +27,9 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int
 argc, char * const argv[]) ret = dfu_init_env_entities(interface,
 simple_strtoul(devstring, NULL, 10));
 	if (ret)
-		return ret;
+		goto done;
 
+	ret = CMD_RET_SUCCESS;
 	if (argc > 4 && strcmp(argv[4], "list") == 0) {
 		dfu_show_entities();
 		goto done;

common/cmd_dfu.c done: · line 68

Quoted 8 lines
common/cmd_dfu.c +1 -1
@@ -61,7 +62,7 @@ done:
 	if (dfu_reset())
 		run_command("reset", 0);
 
-	return CMD_RET_SUCCESS;
+	return ret;
 }
 
 U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,

Test HW: Exynos4412 - Trats2

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group