From 8806a7409af29d48f79d07013c7d015722e2fbc8 Mon Sep 17 00:00:00 2001 From: Ahmed Ismail Date: Wed, 17 Jan 2024 11:06:01 +0000 Subject: [PATCH] freertos-ota-pal: Fix abortion function 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 --- .../freertos_ota_pal_psa/CMakeLists.txt | 7 ++++ ...-abort-Fix-successful-abortion-check.patch | 34 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 components/security/freertos_ota_pal_psa/integration/patches/0001-ota-abort-Fix-successful-abortion-check.patch diff --git a/components/security/freertos_ota_pal_psa/CMakeLists.txt b/components/security/freertos_ota_pal_psa/CMakeLists.txt index 114260d4..7c20a3a2 100644 --- a/components/security/freertos_ota_pal_psa/CMakeLists.txt +++ b/components/security/freertos_ota_pal_psa/CMakeLists.txt @@ -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) diff --git a/components/security/freertos_ota_pal_psa/integration/patches/0001-ota-abort-Fix-successful-abortion-check.patch b/components/security/freertos_ota_pal_psa/integration/patches/0001-ota-abort-Fix-successful-abortion-check.patch new file mode 100644 index 00000000..4a629374 --- /dev/null +++ b/components/security/freertos_ota_pal_psa/integration/patches/0001-ota-abort-Fix-successful-abortion-check.patch @@ -0,0 +1,34 @@ +From 70721e0c00a9e698df467e81e1ad3b54cf76edf4 Mon Sep 17 00:00:00 2001 +From: Ahmed Ismail +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 +--- + 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 +