From patchwork Mon May 11 10:11:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Bisson X-Patchwork-Id: 245580 List-Id: U-Boot discussion From: gary.bisson at boundarydevices.com (Gary Bisson) Date: Mon, 11 May 2020 12:11:53 +0200 Subject: [PATCH v2] cmd: avb: free partition buffer upon verify completion Message-ID: <20200511101153.20396-1-gary.bisson@boundarydevices.com> Doing the same as the unittests for libavb [1]. 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. [1] https://android.googlesource.com/platform/external/avb/+/refs/tags/android-9.0.0_r37/test/avb_slot_verify_unittest.cc#156 Signed-off-by: Gary Bisson Reviewed-by: Igor Opaniuk --- Hi, Changelog v2: - use avb_slot_verity_data_free as suggested by Igor 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/avb.c b/cmd/avb.c index a4de5c40a2..93d1a31819 100644 --- a/cmd/avb.c +++ b/cmd/avb.c @@ -312,6 +312,9 @@ int do_avb_verify_part(cmd_tbl_t *cmdtp, int flag, printf("Unknown error occurred\n"); } + if (out_data) + avb_slot_verify_data_free(out_data); + return res; }