Skip to content

Commit 5f6942b

Browse files
Add ret checks
1 parent b48a9f2 commit 5f6942b

1 file changed

Lines changed: 41 additions & 31 deletions

File tree

hal/mcxn.c

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -521,14 +521,16 @@ int hal_dice_update_cdi(const uint8_t *measurement, size_t meas_len)
521521
MCUX_CSSL_FP_FUNCTION_CALL_END();
522522

523523
/* Wait for hardware to finish */
524-
MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(res_w, tok_w,
525-
mcuxClEls_WaitForOperation(MCUXCLELS_ERROR_FLAGS_CLEAR));
524+
if (ret == 0) {
525+
MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(res_w, tok_w,
526+
mcuxClEls_WaitForOperation(MCUXCLELS_ERROR_FLAGS_CLEAR));
526527

527-
if ((MCUX_CSSL_FP_FUNCTION_CALLED(mcuxClEls_WaitForOperation) != tok_w) ||
528-
(MCUXCLELS_STATUS_OK != res_w))
529-
ret = -1;
528+
if ((MCUX_CSSL_FP_FUNCTION_CALLED(mcuxClEls_WaitForOperation) != tok_w) ||
529+
(MCUXCLELS_STATUS_OK != res_w))
530+
ret = -1;
530531

531-
MCUX_CSSL_FP_FUNCTION_CALL_END();
532+
MCUX_CSSL_FP_FUNCTION_CALL_END();
533+
}
532534
}
533535

534536
if (ret == 0) {
@@ -561,17 +563,19 @@ int hal_dice_update_cdi(const uint8_t *measurement, size_t meas_len)
561563
MCUX_CSSL_FP_FUNCTION_CALL_END();
562564

563565
/* Wait for hardware to finish */
564-
MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(res_w, tok_w,
565-
mcuxClEls_WaitForOperation(MCUXCLELS_ERROR_FLAGS_CLEAR));
566+
if (ret == 0) {
567+
MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(res_w, tok_w,
568+
mcuxClEls_WaitForOperation(MCUXCLELS_ERROR_FLAGS_CLEAR));
566569

567-
if ((MCUX_CSSL_FP_FUNCTION_CALLED(mcuxClEls_WaitForOperation) != tok_w) ||
568-
(MCUXCLELS_STATUS_OK != res_w))
569-
ret = -1;
570+
if ((MCUX_CSSL_FP_FUNCTION_CALLED(mcuxClEls_WaitForOperation) != tok_w) ||
571+
(MCUXCLELS_STATUS_OK != res_w))
572+
ret = -1;
570573

571-
MCUX_CSSL_FP_FUNCTION_CALL_END();
574+
MCUX_CSSL_FP_FUNCTION_CALL_END();
575+
}
572576
}
573577

574-
if (ret == 0)
578+
if (ret == 0)
575579
cdi_step++;
576580

577581
return ret;
@@ -599,14 +603,16 @@ int hal_dice_create_attest_key(void)
599603
MCUX_CSSL_FP_FUNCTION_CALL_END();
600604

601605
/* Wait for hardware to finish */
602-
MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(res_w, tok_w,
603-
mcuxClEls_WaitForOperation(MCUXCLELS_ERROR_FLAGS_CLEAR));
606+
if (ret == 0) {
607+
MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(res_w, tok_w,
608+
mcuxClEls_WaitForOperation(MCUXCLELS_ERROR_FLAGS_CLEAR));
604609

605-
if ((MCUX_CSSL_FP_FUNCTION_CALLED(mcuxClEls_WaitForOperation) != tok_w) ||
606-
(MCUXCLELS_STATUS_OK != res_w))
607-
ret = -1;
610+
if ((MCUX_CSSL_FP_FUNCTION_CALLED(mcuxClEls_WaitForOperation) != tok_w) ||
611+
(MCUXCLELS_STATUS_OK != res_w))
612+
ret = -1;
608613

609-
MCUX_CSSL_FP_FUNCTION_CALL_END();
614+
MCUX_CSSL_FP_FUNCTION_CALL_END();
615+
}
610616

611617
if (ret == 0) {
612618
/* Set KeyGen options */
@@ -639,14 +645,16 @@ int hal_dice_create_attest_key(void)
639645
MCUX_CSSL_FP_FUNCTION_CALL_END();
640646

641647
/* Wait for hardware to finish */
642-
MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(res_w, tok_w,
643-
mcuxClEls_WaitForOperation(MCUXCLELS_ERROR_FLAGS_CLEAR));
648+
if (ret == 0) {
649+
MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(res_w, tok_w,
650+
mcuxClEls_WaitForOperation(MCUXCLELS_ERROR_FLAGS_CLEAR));
644651

645-
if ((MCUX_CSSL_FP_FUNCTION_CALLED(mcuxClEls_WaitForOperation) != tok_w) ||
646-
(MCUXCLELS_STATUS_OK != res_w))
647-
ret = -1;
652+
if ((MCUX_CSSL_FP_FUNCTION_CALLED(mcuxClEls_WaitForOperation) != tok_w) ||
653+
(MCUXCLELS_STATUS_OK != res_w))
654+
ret = -1;
648655

649-
MCUX_CSSL_FP_FUNCTION_CALL_END();
656+
MCUX_CSSL_FP_FUNCTION_CALL_END();
657+
}
650658
}
651659

652660
return ret;
@@ -682,14 +690,16 @@ int hal_dice_sign_hash(const uint8_t *hash, size_t hash_len,
682690
MCUX_CSSL_FP_FUNCTION_CALL_END();
683691

684692
/* Wait for hardware to finish */
685-
MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(res_w, tok_w,
686-
mcuxClEls_WaitForOperation(MCUXCLELS_ERROR_FLAGS_CLEAR));
693+
if (ret == 0) {
694+
MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(res_w, tok_w,
695+
mcuxClEls_WaitForOperation(MCUXCLELS_ERROR_FLAGS_CLEAR));
687696

688-
if ((MCUX_CSSL_FP_FUNCTION_CALLED(mcuxClEls_WaitForOperation) != tok_w) ||
689-
(MCUXCLELS_STATUS_OK != res_w))
690-
ret = -1;
697+
if ((MCUX_CSSL_FP_FUNCTION_CALLED(mcuxClEls_WaitForOperation) != tok_w) ||
698+
(MCUXCLELS_STATUS_OK != res_w))
699+
ret = -1;
691700

692-
MCUX_CSSL_FP_FUNCTION_CALL_END();
701+
MCUX_CSSL_FP_FUNCTION_CALL_END();
702+
}
693703
}
694704

695705
if (ret == 0) {

0 commit comments

Comments
 (0)