From c37a206673aed1c0fef8b3af71fc48996dabebb8 Mon Sep 17 00:00:00 2001 From: Adrien Maillard Date: Fri, 2 May 2025 11:25:45 +0200 Subject: [PATCH] updatehub: use the new API method in autohandler Call updatehub_report_error() when detecting an unconfirmed image in autohandler to ensure the server is notified of the failure before triggering a rollback. Signed-off-by: Adrien Maillard --- subsys/mgmt/updatehub/updatehub.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/subsys/mgmt/updatehub/updatehub.c b/subsys/mgmt/updatehub/updatehub.c index 4494ce94c1a..cd9bfbd2479 100644 --- a/subsys/mgmt/updatehub/updatehub.c +++ b/subsys/mgmt/updatehub/updatehub.c @@ -1001,9 +1001,7 @@ static void autohandler(struct k_work *work) case UPDATEHUB_UNCONFIRMED_IMAGE: LOG_ERR("Image is unconfirmed. Rebooting to revert back to previous" "confirmed image."); - if (report(UPDATEHUB_STATE_ERROR) < 0) { - LOG_ERR("Failed to report rollback error to server"); - } + updatehub_report_error(); LOG_PANIC(); updatehub_reboot(); break; @@ -1049,5 +1047,10 @@ void z_impl_updatehub_autohandler(void) int z_impl_updatehub_report_error(void) { - return report(UPDATEHUB_STATE_ERROR); + int ret = report(UPDATEHUB_STATE_ERROR); + + if (ret < 0) { + LOG_ERR("Failed to report rollback error to server"); + } + return ret; }