Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No if xfree #7839

Merged
merged 12 commits into from
Aug 7, 2024
1 change: 1 addition & 0 deletions IDE/CRYPTOCELL/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ extern "C" {

/* prototypes for user heap override functions */
/* Note: Realloc only required for normal math */
/* Note2: XFREE(NULL) must be properly handled */
#include <stddef.h> /* for size_t */
extern void *myMalloc(size_t n, void* heap, int type);
extern void myFree(void *p, void* heap, int type);
Expand Down
1 change: 1 addition & 0 deletions IDE/GCC-ARM/Header/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ extern "C" {

/* prototypes for user heap override functions */
/* Note: Realloc only required for normal math */
/* Note2: XFREE(NULL) must be properly handled */
#include <stddef.h> /* for size_t */
extern void *myMalloc(size_t n, void* heap, int type);
extern void myFree(void *p, void* heap, int type);
Expand Down
1 change: 1 addition & 0 deletions IDE/NETOS/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ extern "C" {

/* prototypes for user heap override functions */
/* Note: Realloc only required for normal math */
/* Note2: XFREE(NULL) must be properly handled */
#include <stddef.h> /* for size_t */
extern void *myMalloc(size_t n, void* heap, int type);
extern void myFree(void *p, void* heap, int type);
Expand Down
1 change: 1 addition & 0 deletions IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ extern "C" {

/* prototypes for user heap override functions */
/* Note: Realloc only required for normal math */
/* Note2: XFREE(NULL) must be properly handled */
#include <stddef.h> /* for size_t */
extern void *myMalloc(size_t n, void* heap, int type);
extern void myFree(void *p, void* heap, int type);
Expand Down
12 changes: 3 additions & 9 deletions IDE/Renesas/e2studio/RA6M4/test/src/test_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,11 @@ void Clr_CallbackCtx(FSPSM_ST *g)
(void) g;

#if defined(WOLFSSL_RENESAS_SCEPROTECT_CRYPTONLY)
if (g->wrapped_key_rsapri2048 != NULL)
XFREE(g->wrapped_key_rsapri2048,
NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(g->wrapped_key_rsapri2048, NULL, DYNAMIC_TYPE_TMP_BUFFER);

if (g->wrapped_key_rsapub2048 != NULL)
XFREE(g->wrapped_key_rsapub2048,
NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(g->wrapped_key_rsapub2048, NULL, DYNAMIC_TYPE_TMP_BUFFER);

if (g->wrapped_key_rsapri1024 != NULL)
XFREE(g->wrapped_key_rsapri1024,
NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(g->wrapped_key_rsapri1024, NULL, DYNAMIC_TYPE_TMP_BUFFER);

if (g->wrapped_key_rsapub2048 != NULL)
XFREE(g->wrapped_key_rsapub1024,
Expand Down
28 changes: 7 additions & 21 deletions IDE/Renesas/e2studio/RA6M4/test/src/wolfssl_sce_unit_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,18 +691,10 @@ static int sce_rsa_test(int prnt, int keySize)
wc_FreeRsaKey(key);
XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
if (in != NULL) {
XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
if (in2 != NULL) {
XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
if (out != NULL) {
XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
if (out2 != NULL) {
XFREE(out2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(out2, NULL, DYNAMIC_TYPE_TMP_BUFFER);

return ret;
}
Expand Down Expand Up @@ -778,15 +770,9 @@ static int sce_rsa_SignVerify_test(int prnt, int keySize)
wc_FreeRsaKey(key);
XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
if (in != NULL) {
XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
if (in2 != NULL) {
XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
if (out != NULL) {
XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER);

return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,13 @@ typedef struct tagInfo

void Clr_CallbackCtx(TsipUserCtx *g)
{
if (g->rsa1024pri_keyIdx != NULL)
XFREE(g->rsa1024pri_keyIdx,
NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(g->rsa1024pri_keyIdx, NULL, DYNAMIC_TYPE_TMP_BUFFER);

if (g->rsa1024pub_keyIdx != NULL)
XFREE(g->rsa1024pub_keyIdx,
NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(g->rsa1024pub_keyIdx, NULL, DYNAMIC_TYPE_TMP_BUFFER);

if (g->rsa2048pri_keyIdx != NULL)
XFREE(g->rsa2048pri_keyIdx,
NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(g->rsa2048pri_keyIdx, NULL, DYNAMIC_TYPE_TMP_BUFFER);

if (g->rsa2048pub_keyIdx != NULL)
XFREE(g->rsa2048pub_keyIdx,
NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(g->rsa2048pub_keyIdx, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XMEMSET(g, 0, sizeof(TsipUserCtx));
}

Expand Down Expand Up @@ -789,15 +781,9 @@ static int tsip_rsa_SignVerify_test(int prnt, int keySize)
wc_FreeRsaKey(key);
XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
if (in != NULL) {
XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
if (in2 != NULL) {
XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
if (out != NULL) {
XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER);

return ret;
}
Expand Down
28 changes: 7 additions & 21 deletions IDE/Renesas/e2studio/RZN2L/test/src/test/wolfssl_rsip_unit_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,18 +718,10 @@ static int rsip_rsa_test(int prnt, int keySize)
wc_FreeRsaKey(key);
XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
if (in != NULL) {
XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
if (in2 != NULL) {
XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
if (out != NULL) {
XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
if (out2 != NULL) {
XFREE(out2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(out2, NULL, DYNAMIC_TYPE_TMP_BUFFER);

(void) prnt;
return ret;
Expand Down Expand Up @@ -808,15 +800,9 @@ static int rsip_rsa_SignVerify_test(int prnt, int keySize)
wc_FreeRsaKey(key);
XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
if (in != NULL) {
XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
if (in2 != NULL) {
XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
if (out != NULL) {
XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
XFREE(in, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(in2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER);

return ret;
}
Expand Down
1 change: 1 addition & 0 deletions IDE/STARCORE/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ extern "C" {

/* prototypes for user heap override functions */
/* Note: Realloc only required for normal math */
/* Note2: XFREE(NULL) must be properly handled */
#include <stddef.h> /* for size_t */
extern void *myMalloc(size_t n, void* heap, int type);
extern void myFree(void *p, void* heap, int type);
Expand Down
8 changes: 2 additions & 6 deletions IDE/STM32Cube/wolfssl_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -1700,9 +1700,7 @@ static int tls13_uart_server(void)
}

#ifdef WOLFSSL_SMALL_STACK
if (tbuf != NULL) {
XFREE(tbuf, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
XFREE(tbuf, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif

return ret;
Expand Down Expand Up @@ -1795,9 +1793,7 @@ static int tls13_uart_client(void)
wolfSSL_CTX_free(ctx);
}
#ifdef WOLFSSL_SMALL_STACK
if (tbuf != NULL) {
XFREE(tbuf, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
XFREE(tbuf, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif

return ret;
Expand Down
1 change: 1 addition & 0 deletions IDE/SimplicityStudio/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ extern "C" {

/* prototypes for user heap override functions */
/* Note: Realloc only required for normal math */
/* Note2: XFREE(NULL) must be properly handled */
#include <stddef.h> /* for size_t */
extern void *myMalloc(size_t n, void* heap, int type);
extern void myFree(void *p, void* heap, int type);
Expand Down
1 change: 1 addition & 0 deletions IDE/WICED-STUDIO/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ extern "C" {

/* prototypes for user heap override functions */
/* Note: Realloc only required for normal math */
/* Note2: XFREE(NULL) must be properly handled */
#include <stddef.h> /* for size_t */
extern void *myMalloc(size_t n, void* heap, int type);
extern void myFree(void *p, void* heap, int type);
Expand Down
1 change: 1 addition & 0 deletions IDE/WINCE/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ extern "C" {

/* prototypes for user heap override functions */
/* Note: Realloc only required for normal math */
/* Note2: XFREE(NULL) must be properly handled */
#include <stddef.h> /* for size_t */
extern void *myMalloc(size_t n, void* heap, int type);
extern void myFree(void *p, void* heap, int type);
Expand Down
1 change: 1 addition & 0 deletions IDE/XCODE-FIPSv2/macOS-C++/Intel/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ extern "C" {

/* prototypes for user heap override functions */
/* Note: Realloc only required for normal math */
/* Note2: XFREE(NULL) must be properly handled */
#include <stddef.h> /* for size_t */
extern void *myMalloc(size_t n, void* heap, int type);
extern void myFree(void *p, void* heap, int type);
Expand Down
1 change: 1 addition & 0 deletions IDE/XCODE-FIPSv2/macOS-C++/M1/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ extern "C" {

/* prototypes for user heap override functions */
/* Note: Realloc only required for normal math */
/* Note2: XFREE(NULL) must be properly handled */
#include <stddef.h> /* for size_t */
extern void *myMalloc(size_t n, void* heap, int type);
extern void myFree(void *p, void* heap, int type);
Expand Down
1 change: 1 addition & 0 deletions IDE/XCODE-FIPSv2/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ extern "C" {

/* prototypes for user heap override functions */
/* Note: Realloc only required for normal math */
/* Note2: XFREE(NULL) must be properly handled */
#include <stddef.h> /* for size_t */
extern void *myMalloc(size_t n, void* heap, int type);
extern void myFree(void *p, void* heap, int type);
Expand Down
1 change: 1 addition & 0 deletions IDE/XCODE-FIPSv5/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ extern "C" {

/* prototypes for user heap override functions */
/* Note: Realloc only required for normal math */
/* Note2: XFREE(NULL) must be properly handled */
#include <stddef.h> /* for size_t */
extern void *myMalloc(size_t n, void* heap, int type);
extern void myFree(void *p, void* heap, int type);
Expand Down
1 change: 1 addition & 0 deletions examples/configs/user_settings_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ extern "C" {

/* prototypes for user heap override functions */
/* Note: Realloc only required for normal math */
/* Note2: XFREE(NULL) must be properly handled */
#include <stddef.h> /* for size_t */
extern void *myMalloc(size_t n, void* heap, int type);
extern void myFree(void *p, void* heap, int type);
Expand Down
6 changes: 2 additions & 4 deletions examples/server/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -3533,10 +3533,8 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)

size = wolfSSL_get_server_random(ssl, rnd, size);
if (size == 0) {
if (rnd) {
XFREE(rnd, NULL, DYNAMIC_TYPE_TMP_BUFFER);
rnd = NULL;
}
XFREE(rnd, NULL, DYNAMIC_TYPE_TMP_BUFFER);
rnd = NULL;
err_sys_ex(runWithErrors, "error getting server random buffer");
}

Expand Down
49 changes: 16 additions & 33 deletions linuxkm/lkcapi_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -2451,34 +2451,25 @@ static int aes_xts_128_test(void)

test_xts_end:

if (enc2)
XFREE(enc2, NULL, DYNAMIC_TYPE_AES);
if (dec2)
XFREE(dec2, NULL, DYNAMIC_TYPE_AES);
if (src)
XFREE(src, NULL, DYNAMIC_TYPE_AES);
if (dst)
XFREE(dst, NULL, DYNAMIC_TYPE_AES);
XFREE(enc2, NULL, DYNAMIC_TYPE_AES);
XFREE(dec2, NULL, DYNAMIC_TYPE_AES);
XFREE(src, NULL, DYNAMIC_TYPE_AES);
XFREE(dst, NULL, DYNAMIC_TYPE_AES);
if (req)
skcipher_request_free(req);
if (tfm)
crypto_free_skcipher(tfm);

out:

if (large_input)
XFREE(large_input, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(large_input, NULL, DYNAMIC_TYPE_TMP_BUFFER);

if (aes_inited)
wc_AesXtsFree(aes);

if (buf)
XFREE(buf, NULL, DYNAMIC_TYPE_AES);
if (cipher)
XFREE(cipher, NULL, DYNAMIC_TYPE_AES);

if (aes)
XFREE(aes, NULL, DYNAMIC_TYPE_AES);
XFREE(buf, NULL, DYNAMIC_TYPE_AES);
XFREE(cipher, NULL, DYNAMIC_TYPE_AES);
XFREE(aes, NULL, DYNAMIC_TYPE_AES);

#undef AES_XTS_128_TEST_BUF_SIZ

Expand Down Expand Up @@ -2939,34 +2930,26 @@ static int aes_xts_256_test(void)

test_xts_end:

if (enc2)
XFREE(enc2, NULL, DYNAMIC_TYPE_AES);
if (dec2)
XFREE(dec2, NULL, DYNAMIC_TYPE_AES);
if (src)
XFREE(src, NULL, DYNAMIC_TYPE_AES);
if (dst)
XFREE(dst, NULL, DYNAMIC_TYPE_AES);
XFREE(enc2, NULL, DYNAMIC_TYPE_AES);
XFREE(dec2, NULL, DYNAMIC_TYPE_AES);
XFREE(src, NULL, DYNAMIC_TYPE_AES);
XFREE(dst, NULL, DYNAMIC_TYPE_AES);
if (req)
skcipher_request_free(req);
if (tfm)
crypto_free_skcipher(tfm);

out:

if (large_input)
XFREE(large_input, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(large_input, NULL, DYNAMIC_TYPE_TMP_BUFFER);

if (aes_inited)
wc_AesXtsFree(aes);

if (buf)
XFREE(buf, NULL, DYNAMIC_TYPE_AES);
if (cipher)
XFREE(cipher, NULL, DYNAMIC_TYPE_AES);
XFREE(buf, NULL, DYNAMIC_TYPE_AES);
XFREE(cipher, NULL, DYNAMIC_TYPE_AES);

if (aes)
XFREE(aes, NULL, DYNAMIC_TYPE_AES);
XFREE(aes, NULL, DYNAMIC_TYPE_AES);

#undef AES_XTS_256_TEST_BUF_SIZ

Expand Down
15 changes: 5 additions & 10 deletions linuxkm/module_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,16 +803,11 @@ static int updateFipsHash(void)

if (tfm != NULL)
crypto_free_shash(tfm);
if (desc != NULL)
XFREE(desc, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (hash != NULL)
XFREE(hash, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (base16_hash != NULL)
XFREE(base16_hash, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (binCoreKey != NULL)
XFREE(binCoreKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (binVerify != NULL)
XFREE(binVerify, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(desc, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(hash, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(base16_hash, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(binCoreKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(binVerify, NULL, DYNAMIC_TYPE_TMP_BUFFER);

return ret;
}
Expand Down
Loading