Commit afb8e71caea6784e8c3ff18cab7f27c46511878a

Authored by Stephen Warren
Committed by Marek Vasut
1 parent 08ebd467c8

dfu: free entities when parsing fails

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.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Lukasz Majewski <l.majewski@samsung.com>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>

Showing 1 changed file with 3 additions and 2 deletions Side-by-side Diff

... ... @@ -27,8 +27,9 @@
27 27 ret = dfu_init_env_entities(interface, simple_strtoul(devstring,
28 28 NULL, 10));
29 29 if (ret)
30   - return ret;
  30 + goto done;
31 31  
  32 + ret = CMD_RET_SUCCESS;
32 33 if (argc > 4 && strcmp(argv[4], "list") == 0) {
33 34 dfu_show_entities();
34 35 goto done;
... ... @@ -61,7 +62,7 @@
61 62 if (dfu_reset())
62 63 run_command("reset", 0);
63 64  
64   - return CMD_RET_SUCCESS;
  65 + return ret;
65 66 }
66 67  
67 68 U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,