From: Alexey Romanov Date: Mon, 25 Dec 2023 10:22:45 +0000 (+0300) Subject: android_ab: don't ignore ab_control_store return code X-Git-Url: http://git.dujemihanovic.xyz/%22/img/sics.gif/%22/static/git-favicon.png?a=commitdiff_plain;h=bf2df680286956b3187b1820ae54c5a0fb594857;p=u-boot.git android_ab: don't ignore ab_control_store return code ab_control_store() can return an error if writing to disk fails. In this case, we have to pass the error code to the caller. Signed-off-by: Alexey Romanov Reviewed-by: Mattijs Korpershoek --- diff --git a/boot/android_ab.c b/boot/android_ab.c index 0f20a34e51..c9df6d2b4b 100644 --- a/boot/android_ab.c +++ b/boot/android_ab.c @@ -336,7 +336,14 @@ int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info, if (store_needed) { abc->crc32_le = ab_control_compute_crc(abc); - ab_control_store(dev_desc, part_info, abc, 0); + ret = ab_control_store(dev_desc, part_info, abc, 0); + if (ret < 0) { +#if ANDROID_AB_BACKUP_OFFSET + free(backup_abc); +#endif + free(abc); + return ret; + } } #if ANDROID_AB_BACKUP_OFFSET @@ -345,8 +352,13 @@ int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info, * to the backup offset */ if (memcmp(backup_abc, abc, sizeof(*abc)) != 0) { - ab_control_store(dev_desc, part_info, abc, - ANDROID_AB_BACKUP_OFFSET); + ret = ab_control_store(dev_desc, part_info, abc, + ANDROID_AB_BACKUP_OFFSET); + if (ret < 0) { + free(backup_abc); + free(abc); + return ret; + } } free(backup_abc); #endif