Skip to content

Commit

Permalink
freertos-ota-pal: Fix abortion function
Browse files Browse the repository at this point in the history
Fix firmware update cancellation and cleanup check
by ensuring the result variable is initialized to
the success value. The result variable was only set
in case of failure if the cancellation and/or the
cleanup failed.

Signed-off-by: Ahmed Ismail <[email protected]>
  • Loading branch information
AhmedIsmail02 authored and urutva committed Feb 5, 2024
1 parent 559d9dd commit 53dab5d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
7 changes: 7 additions & 0 deletions components/security/freertos_ota_pal_psa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@ set(freertos_ota_pal_psa_SOURCE_DIR
"Path to FreeRTOS OTA PAL based on PSA API source code"
)

execute_process(COMMAND git am --abort
COMMAND git am ${CMAKE_CURRENT_LIST_DIR}/integration/patches/0001-ota-abort-Fix-successful-abortion-check.patch
WORKING_DIRECTORY ${freertos_ota_pal_psa_SOURCE_DIR}
OUTPUT_QUIET
ERROR_QUIET
)

add_subdirectory(integration)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From 70721e0c00a9e698df467e81e1ad3b54cf76edf4 Mon Sep 17 00:00:00 2001
From: Ahmed Ismail <[email protected]>
Date: Wed, 17 Jan 2024 11:00:09 +0000
Subject: [PATCH] ota-abort: Fix successful abortion check

PsaStatus variable should be initialized before
being accessed as in the happy path scenario the
variable wouldn't be modified as the psa_fwu_cancel()
and psa_fwu_clean() functions wouldn't be failing. Hence
the variable would be accessed before being initialized
means that a garbage value would be checked
which is not the correct case.

Signed-off-by: Ahmed Ismail <[email protected]>
---
ota_pal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ota_pal.c b/ota_pal.c
index 14b2e80..165c146 100644
--- a/ota_pal.c
+++ b/ota_pal.c
@@ -282,7 +282,7 @@ OtaPalStatus_t otaPal_Abort( OtaFileContext_t * const pFileContext )
}
else
{
- psa_status_t lPsaStatus;
+ psa_status_t lPsaStatus = PSA_SUCCESS;
if( psa_fwu_cancel( xOTAComponentID ) != PSA_SUCCESS )
{
lPsaStatus = OTA_PAL_COMBINE_ERR( OtaPalAbortFailed, 0 );
--
2.34.1

0 comments on commit 53dab5d

Please sign in to comment.