[PATCH v2] android_ab: don't ignore ab_control_store return code

Alexey Romanov avromanov at salutedevices.com
Tue Jan 9 11:37:25 CET 2024


+ Tom Rini

Hello! Please, ping

On Mon, Dec 25, 2023 at 01:22:45PM +0300, Alexey Romanov wrote:
> 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 at salutedevices.com>
> Reviewed-by: Mattijs Korpershoek <mkorpershoek at baylibre.com>
> ---
>  boot/android_ab.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/boot/android_ab.c b/boot/android_ab.c
> index 73b55c196c..af3c375e07 100644
> --- a/boot/android_ab.c
> +++ b/boot/android_ab.c
> @@ -337,7 +337,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
> @@ -346,8 +353,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,
> +		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
> -- 
> 2.39.2
> 

-- 
Thank you,
Alexey


More information about the U-Boot mailing list