Skip to content

Commit 11001c8

Browse files
authored
Merge pull request #8644 from lealem47/zd19343
CMSIS: Skip Mutex calls if OS isn't running
2 parents 1fb8f5f + 17953d0 commit 11001c8

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

wolfcrypt/src/wc_port.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,6 +2845,11 @@ int wolfSSL_HwPkMutexUnLock(void)
28452845
int wc_InitMutex(wolfSSL_Mutex* m)
28462846
{
28472847
int i;
2848+
2849+
if(!osKernelRunning()) {
2850+
return 0;
2851+
}
2852+
28482853
for (i=0; i<CMSIS_NMUTEX; i++) {
28492854
if(CMSIS_mutexID[i] == 0) {
28502855
CMSIS_mutexID[i] = osMutexCreate(CMSIS_mutex[i]);
@@ -2858,6 +2863,11 @@ int wolfSSL_HwPkMutexUnLock(void)
28582863
int wc_FreeMutex(wolfSSL_Mutex* m)
28592864
{
28602865
int i;
2866+
2867+
if(!osKernelRunning()) {
2868+
return 0;
2869+
}
2870+
28612871
osMutexDelete (*m);
28622872
for (i=0; i<CMSIS_NMUTEX; i++) {
28632873
if(CMSIS_mutexID[i] == (*m)) {
@@ -2870,13 +2880,17 @@ int wolfSSL_HwPkMutexUnLock(void)
28702880

28712881
int wc_LockMutex(wolfSSL_Mutex* m)
28722882
{
2873-
osMutexWait(*m, osWaitForever);
2883+
if(osKernelRunning()) {
2884+
osMutexWait(*m, osWaitForever);
2885+
}
28742886
return(0);
28752887
}
28762888

28772889
int wc_UnLockMutex(wolfSSL_Mutex* m)
28782890
{
2879-
osMutexRelease (*m);
2891+
if(osKernelRunning()) {
2892+
osMutexRelease (*m);
2893+
}
28802894
return 0;
28812895
}
28822896

0 commit comments

Comments
 (0)