Skip to content

Commit 308893a

Browse files
committed
Fix for possible double free case where ctx->symCtx is not trapped. Improved debug messages.
1 parent 34b3013 commit 308893a

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

wolfcrypt/src/port/intel/quickassist.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ int IntelQaHardwareStart(const char* process_name, int limitDevAccess)
348348
Cpa32U coreAffinity = 0;
349349
CpaCySymCapabilitiesInfo capabilities;
350350
int j;
351+
XMEMSET(&capabilities, 0, sizeof(capabilities));
351352

352353
status = cpaCyInstanceGetInfo2(g_cyInstances[i],
353354
&g_cyInstanceInfo[i]);
@@ -1416,11 +1417,11 @@ static int IntelQaSymClose(WC_ASYNC_DEV* dev, int doFree)
14161417
#endif
14171418

14181419
#ifdef QAT_DEBUG
1419-
printf("IntelQaSymClose: dev %p, symCtx %p (src %p), symCtxSize %d, isCopy %d, isOpen %d, doFree %d\n",
1420-
dev, ctx->symCtx, ctx->symCtxSrc, ctx->symCtxSize, ctx->isCopy, ctx->isOpen, doFree);
1420+
printf("IntelQaSymClose: dev %p, ctx %p, symCtx %p (src %p), symCtxSize %d, isCopy %d, isOpen %d, doFree %d\n",
1421+
dev, ctx, ctx->symCtx, ctx->symCtxSrc, ctx->symCtxSize, ctx->isCopy, ctx->isOpen, doFree);
14211422
#endif
14221423

1423-
if (ctx->symCtx == ctx->symCtxSrc) {
1424+
if (ctx->symCtx == ctx->symCtxSrc && ctx->symCtx != NULL) {
14241425
if (ctx->isOpen) {
14251426
ctx->isOpen = 0;
14261427
#ifdef QAT_DEBUG

wolfcrypt/src/port/intel/quickassist_mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ static void* _qaeMemAlloc(size_t size, void* heap, int type
428428

429429
#ifdef WOLFSSL_DEBUG_MEMORY
430430
#ifdef WOLFSSL_DEBUG_MEMORY_PRINT
431-
printf("Malloc: %p (%u) at %s:%d, heap %p, type %d\n",
431+
printf("Alloc: %p (%u) at %s:%d, heap %p, type %d\n",
432432
ptr, (unsigned int)size, func, line, heap, type);
433433
#else
434434
(void)func;

0 commit comments

Comments
 (0)