]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
android_ab: don't ignore ab_control_store return code
authorAlexey Romanov <avromanov@salutedevices.com>
Mon, 25 Dec 2023 10:22:45 +0000 (13:22 +0300)
committerTom Rini <trini@konsulko.com>
Fri, 12 Jan 2024 03:14:57 +0000 (22:14 -0500)
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 <avromanov@salutedevices.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
boot/android_ab.c

index 0f20a34e5110c15df640bc177a50b06de47076d6..c9df6d2b4b17d00968b2addce1d3587212cb322c 100644 (file)
@@ -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