From patchwork Wed May 6 14:05:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Bisson X-Patchwork-Id: 245198 List-Id: U-Boot discussion From: gary.bisson at boundarydevices.com (Gary Bisson) Date: Wed, 6 May 2020 16:05:57 +0200 Subject: [PATCH] cmd: avb: free partition buffer upon verify completion Message-ID: <20200506140557.505309-1-gary.bisson@boundarydevices.com> Allows to run 'avb verify' multiple times which can be useful after a failure to be able to re-flash the partition and try again. Signed-off-by: Gary Bisson --- Hi, This was added because of the following scenario: 1- fastboot flash boot boot.img 2- avb verify -> fails because vbmeta wasn't updated 3- fastboot flash vbmeta vbmeta.img 4- avb verify -> fails because it can't allocate memory as previous buffer wasn't freed Let me know if you have any questions. Regards, Gary --- cmd/avb.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/avb.c b/cmd/avb.c index a4de5c40a2..67154de4e1 100644 --- a/cmd/avb.c +++ b/cmd/avb.c @@ -312,6 +312,14 @@ int do_avb_verify_part(cmd_tbl_t *cmdtp, int flag, printf("Unknown error occurred\n"); } + /* Free image buffers now that verification is complete */ + if (slot_result != AVB_SLOT_VERIFY_RESULT_ERROR_OOM) { + int i; + for (i = 0; i < (int)out_data->num_loaded_partitions; i++) + if (out_data->loaded_partitions[i].data) + free(out_data->loaded_partitions[i].data); + } + return res; }