Merge pull request #4682 from JacobBarthelmeh/qnx

add check on mutex lock return value with qnx CAAM
pull/4725/head
David Garske 2022-01-04 14:36:40 -08:00 committed by GitHub
commit be69412e27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 24 deletions

View File

@ -5,7 +5,7 @@ PLATFORM = armv7le
OUTPUT_DIR = build
TARGET = $(ARTIFACT)
CC = qcc -Vgcc_nto$(PLATFORM)
CC ?= qcc -Vgcc_nto$(PLATFORM)
CXX = qcc -lang-c++ -Vgcc_nto$(PLATFORM)
LD = $(CC)

View File

@ -5,7 +5,7 @@ PLATFORM = armv7le
OUTPUT_DIR = build
TARGET = $(ARTIFACT)
CC = qcc -Vgcc_nto$(PLATFORM)
CC ?= qcc -Vgcc_nto$(PLATFORM)
CXX = qcc -lang-c++ -Vgcc_nto$(PLATFORM)
LD = $(CC)

View File

@ -5,7 +5,7 @@ PLATFORM = armv7le
OUTPUT_DIR = build
TARGET = $(ARTIFACT)
CC = qcc -Vgcc_nto$(PLATFORM)
CC ?= qcc -Vgcc_nto$(PLATFORM)
CXX = qcc -lang-c++ -Vgcc_nto$(PLATFORM)
LD = $(CC)

View File

@ -5,7 +5,7 @@ PLATFORM = armv7le
OUTPUT_DIR = build
TARGET = $(ARTIFACT)
CC = qcc -Vgcc_nto$(PLATFORM)
CC ?= qcc -Vgcc_nto$(PLATFORM)
CXX = qcc -lang-c++ -Vgcc_nto$(PLATFORM)
LD = $(CC)

View File

@ -536,9 +536,13 @@ static int doECDSA_KEYPAIR(resmgr_context_t *ctp, io_devctl_t *msg, unsigned int
}
/* claim ownership of a secure memory location */
pthread_mutex_lock(&sm_mutex);
if (pthread_mutex_lock(&sm_mutex) != EOK) {
return ECANCELED;
}
else {
sm_ownerId[args[2]] = (CAAM_ADDRESS)ocb;
pthread_mutex_unlock(&sm_mutex);
}
return EOK;
}
@ -944,9 +948,13 @@ static int doGET_PART(resmgr_context_t *ctp, io_devctl_t *msg,
SETIOV(&out_iov, &partAddr, sizeof(CAAM_ADDRESS));
resmgr_msgwritev(ctp, &out_iov, 1, sizeof(msg->o));
pthread_mutex_lock(&sm_mutex);
if (pthread_mutex_lock(&sm_mutex) != EOK) {
return ECANCELED;
}
else {
sm_ownerId[partNumber] = (CAAM_ADDRESS)ocb;
pthread_mutex_unlock(&sm_mutex);
}
return EOK;
}
@ -1116,10 +1124,14 @@ int io_devctl (resmgr_context_t *ctp, io_devctl_t *msg, iofunc_ocb_t *ocb)
case WC_CAAM_FREE_PART:
caamFreePart(args[0]);
pthread_mutex_lock(&sm_mutex);
if (pthread_mutex_lock(&sm_mutex) != EOK) {
ret = ECANCELED;
}
else {
sm_ownerId[args[0]] = 0;
pthread_mutex_unlock(&sm_mutex);
ret = EOK;
}
break;
case WC_CAAM_FIND_PART:
@ -1165,7 +1177,10 @@ int io_close_ocb(resmgr_context_t *ctp, void *reserved, RESMGR_OCB_T *ocb)
WOLFSSL_MSG("shutting down");
/* free up any dangling owned memory */
pthread_mutex_lock(&sm_mutex);
if (pthread_mutex_lock(&sm_mutex) != EOK) {
return ECANCELED;
}
else {
for (i = 0; i < MAX_PART; i++) {
if (sm_ownerId[i] == (CAAM_ADDRESS)ocb) {
sm_ownerId[i] = 0;
@ -1176,6 +1191,7 @@ int io_close_ocb(resmgr_context_t *ctp, void *reserved, RESMGR_OCB_T *ocb)
}
}
pthread_mutex_unlock(&sm_mutex);
}
return iofunc_close_ocb_default(ctp, reserved, ocb);
}