]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
dfu: Fix data abort in dfu_free_entities()
authorSam Protsenko <semen.protsenko@linaro.org>
Fri, 13 Jul 2018 13:35:45 +0000 (16:35 +0300)
committerMarek Vasut <marex@denx.de>
Wed, 8 Aug 2018 20:22:08 +0000 (22:22 +0200)
Commit 5d8fae79163e ("dfu: avoid memory leak") brings a regression which
described below. This patch is effectively reverting that commit, adding
corresponding comment to avoid such regressions in future.

In case of error in dfu_config_entities(), it frees "dfu" array, which
leads to "data abort" in dfu_free_entities(), which tries to free the
same array (and even tries to access it from linked list first). The
issue occurs e.g. when partition table on device does not match
$dfu_alt_info layout:

    => dfu 0 mmc 1
    Couldn't find part #2 on mmc device #1
    DFU entities configuration failed!
    data abort

To fix this issue, do not free "dfu" array in dfu_config_entities(). It
will be freed later in dfu_free_entities().

Tested on BeagleBone Black (where this regression was originally found).

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
drivers/dfu/dfu.c

index e7c91193b9899a3e39302557ab6ab0199cd162cf..a3c09334b7b243171994186c2d275b901b406249 100644 (file)
@@ -462,7 +462,7 @@ int dfu_config_entities(char *env, char *interface, char *devstr)
                ret = dfu_fill_entity(&dfu[i], s, alt_num_cnt, interface,
                                      devstr);
                if (ret) {
-                       free(dfu);
+                       /* We will free "dfu" in dfu_free_entities() */
                        return -1;
                }