Skip to content

Commit b1edb08

Browse files
committed
linuxkm/linuxkm_wc_port.h:
* fix WC_LINUXKM_ROUND_UP_P_OF_2() to not round up values that are already powers of 2, nor values larger than 8192. linuxkm/lkcapi_glue.c: * fix gating on km_AesSetKeyCommon(). * small stack refactors of Aes objects in self-test routines. * change kmalloc/free to malloc/free in self-test routines. * fix error-path "return"s to "goto exit"s in self-test routines. * fix memory leak around large_input in aes_xts_128_test(). wolfcrypt/benchmark/benchmark.c: * smallstack refactors in bench_chacha() and bench_chacha20_poly1305_aead(). * add error handling in bench_chacha(). wolfcrypt/src/chacha20_poly1305.c: smallstack refactor for wc_ChaCha20Poly1305_Encrypt() and wc_ChaCha20Poly1305_Decrypt().
1 parent 95eb179 commit b1edb08

4 files changed

Lines changed: 199 additions & 109 deletions

File tree

linuxkm/linuxkm_wc_port.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -809,11 +809,13 @@
809809
/* fun fact: since linux commit 59bb47985c, kmalloc with power-of-2 size is
810810
* aligned to the size.
811811
*/
812-
#define WC_LINUXKM_ROUND_UP_P_OF_2(x) ( \
813-
{ \
814-
size_t _alloc_sz = (x); \
815-
_alloc_sz = 1UL << ((sizeof(_alloc_sz) * 8UL) - __builtin_clzl(_alloc_sz)); \
816-
_alloc_sz; \
812+
#define WC_LINUXKM_ROUND_UP_P_OF_2(x) ( \
813+
{ \
814+
size_t _alloc_sz = (x); \
815+
if (_alloc_sz < 8192) \
816+
_alloc_sz = 1UL << \
817+
((sizeof(_alloc_sz) * 8UL) - __builtin_clzl(_alloc_sz - 1)); \
818+
_alloc_sz; \
817819
})
818820
#ifdef HAVE_KVMALLOC
819821
#define malloc(size) kvmalloc_node(WC_LINUXKM_ROUND_UP_P_OF_2(size), GFP_KERNEL, NUMA_NO_NODE)

0 commit comments

Comments
 (0)