forked from wolfSSL/wolfssl
Merge pull request #4682 from JacobBarthelmeh/qnx
add check on mutex lock return value with qnx CAAM
This commit is contained in:
@ -5,7 +5,7 @@ PLATFORM = armv7le
|
|||||||
OUTPUT_DIR = build
|
OUTPUT_DIR = build
|
||||||
TARGET = $(ARTIFACT)
|
TARGET = $(ARTIFACT)
|
||||||
|
|
||||||
CC = qcc -Vgcc_nto$(PLATFORM)
|
CC ?= qcc -Vgcc_nto$(PLATFORM)
|
||||||
CXX = qcc -lang-c++ -Vgcc_nto$(PLATFORM)
|
CXX = qcc -lang-c++ -Vgcc_nto$(PLATFORM)
|
||||||
LD = $(CC)
|
LD = $(CC)
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ PLATFORM = armv7le
|
|||||||
OUTPUT_DIR = build
|
OUTPUT_DIR = build
|
||||||
TARGET = $(ARTIFACT)
|
TARGET = $(ARTIFACT)
|
||||||
|
|
||||||
CC = qcc -Vgcc_nto$(PLATFORM)
|
CC ?= qcc -Vgcc_nto$(PLATFORM)
|
||||||
CXX = qcc -lang-c++ -Vgcc_nto$(PLATFORM)
|
CXX = qcc -lang-c++ -Vgcc_nto$(PLATFORM)
|
||||||
LD = $(CC)
|
LD = $(CC)
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ PLATFORM = armv7le
|
|||||||
OUTPUT_DIR = build
|
OUTPUT_DIR = build
|
||||||
TARGET = $(ARTIFACT)
|
TARGET = $(ARTIFACT)
|
||||||
|
|
||||||
CC = qcc -Vgcc_nto$(PLATFORM)
|
CC ?= qcc -Vgcc_nto$(PLATFORM)
|
||||||
CXX = qcc -lang-c++ -Vgcc_nto$(PLATFORM)
|
CXX = qcc -lang-c++ -Vgcc_nto$(PLATFORM)
|
||||||
LD = $(CC)
|
LD = $(CC)
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ PLATFORM = armv7le
|
|||||||
OUTPUT_DIR = build
|
OUTPUT_DIR = build
|
||||||
TARGET = $(ARTIFACT)
|
TARGET = $(ARTIFACT)
|
||||||
|
|
||||||
CC = qcc -Vgcc_nto$(PLATFORM)
|
CC ?= qcc -Vgcc_nto$(PLATFORM)
|
||||||
CXX = qcc -lang-c++ -Vgcc_nto$(PLATFORM)
|
CXX = qcc -lang-c++ -Vgcc_nto$(PLATFORM)
|
||||||
LD = $(CC)
|
LD = $(CC)
|
||||||
|
|
||||||
|
@ -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 */
|
/* claim ownership of a secure memory location */
|
||||||
pthread_mutex_lock(&sm_mutex);
|
if (pthread_mutex_lock(&sm_mutex) != EOK) {
|
||||||
sm_ownerId[args[2]] = (CAAM_ADDRESS)ocb;
|
return ECANCELED;
|
||||||
pthread_mutex_unlock(&sm_mutex);
|
}
|
||||||
|
else {
|
||||||
|
sm_ownerId[args[2]] = (CAAM_ADDRESS)ocb;
|
||||||
|
pthread_mutex_unlock(&sm_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
return EOK;
|
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));
|
SETIOV(&out_iov, &partAddr, sizeof(CAAM_ADDRESS));
|
||||||
resmgr_msgwritev(ctp, &out_iov, 1, sizeof(msg->o));
|
resmgr_msgwritev(ctp, &out_iov, 1, sizeof(msg->o));
|
||||||
|
|
||||||
pthread_mutex_lock(&sm_mutex);
|
if (pthread_mutex_lock(&sm_mutex) != EOK) {
|
||||||
sm_ownerId[partNumber] = (CAAM_ADDRESS)ocb;
|
return ECANCELED;
|
||||||
pthread_mutex_unlock(&sm_mutex);
|
}
|
||||||
|
else {
|
||||||
|
sm_ownerId[partNumber] = (CAAM_ADDRESS)ocb;
|
||||||
|
pthread_mutex_unlock(&sm_mutex);
|
||||||
|
}
|
||||||
return EOK;
|
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:
|
case WC_CAAM_FREE_PART:
|
||||||
caamFreePart(args[0]);
|
caamFreePart(args[0]);
|
||||||
|
|
||||||
pthread_mutex_lock(&sm_mutex);
|
if (pthread_mutex_lock(&sm_mutex) != EOK) {
|
||||||
sm_ownerId[args[0]] = 0;
|
ret = ECANCELED;
|
||||||
pthread_mutex_unlock(&sm_mutex);
|
}
|
||||||
ret = EOK;
|
else {
|
||||||
|
sm_ownerId[args[0]] = 0;
|
||||||
|
pthread_mutex_unlock(&sm_mutex);
|
||||||
|
ret = EOK;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WC_CAAM_FIND_PART:
|
case WC_CAAM_FIND_PART:
|
||||||
@ -1165,17 +1177,21 @@ int io_close_ocb(resmgr_context_t *ctp, void *reserved, RESMGR_OCB_T *ocb)
|
|||||||
WOLFSSL_MSG("shutting down");
|
WOLFSSL_MSG("shutting down");
|
||||||
|
|
||||||
/* free up any dangling owned memory */
|
/* free up any dangling owned memory */
|
||||||
pthread_mutex_lock(&sm_mutex);
|
if (pthread_mutex_lock(&sm_mutex) != EOK) {
|
||||||
for (i = 0; i < MAX_PART; i++) {
|
return ECANCELED;
|
||||||
if (sm_ownerId[i] == (CAAM_ADDRESS)ocb) {
|
}
|
||||||
sm_ownerId[i] = 0;
|
else {
|
||||||
#if defined(WOLFSSL_CAAM_DEBUG) || defined(WOLFSSL_CAAM_PRINT)
|
for (i = 0; i < MAX_PART; i++) {
|
||||||
printf("found dangiling partition at index %d\n", i);
|
if (sm_ownerId[i] == (CAAM_ADDRESS)ocb) {
|
||||||
#endif
|
sm_ownerId[i] = 0;
|
||||||
caamFreePart(i);
|
#if defined(WOLFSSL_CAAM_DEBUG) || defined(WOLFSSL_CAAM_PRINT)
|
||||||
}
|
printf("found dangiling partition at index %d\n", i);
|
||||||
|
#endif
|
||||||
|
caamFreePart(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&sm_mutex);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&sm_mutex);
|
|
||||||
return iofunc_close_ocb_default(ctp, reserved, ocb);
|
return iofunc_close_ocb_default(ctp, reserved, ocb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user