Skip to content

Commit 30366a9

Browse files
authored
Merge pull request #7293 from douzzer/20240301-linuxkm-leak-and-small-stack-fixes
20240301-linuxkm-leak-and-small-stack-fixes
2 parents ee3aff1 + b1edb08 commit 30366a9

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
@@ -810,11 +810,13 @@
810810
/* fun fact: since linux commit 59bb47985c, kmalloc with power-of-2 size is
811811
* aligned to the size.
812812
*/
813-
#define WC_LINUXKM_ROUND_UP_P_OF_2(x) ( \
814-
{ \
815-
size_t _alloc_sz = (x); \
816-
_alloc_sz = 1UL << ((sizeof(_alloc_sz) * 8UL) - __builtin_clzl(_alloc_sz)); \
817-
_alloc_sz; \
813+
#define WC_LINUXKM_ROUND_UP_P_OF_2(x) ( \
814+
{ \
815+
size_t _alloc_sz = (x); \
816+
if (_alloc_sz < 8192) \
817+
_alloc_sz = 1UL << \
818+
((sizeof(_alloc_sz) * 8UL) - __builtin_clzl(_alloc_sz - 1)); \
819+
_alloc_sz; \
818820
})
819821
#ifdef HAVE_KVMALLOC
820822
#define malloc(size) kvmalloc_node(WC_LINUXKM_ROUND_UP_P_OF_2(size), GFP_KERNEL, NUMA_NO_NODE)

0 commit comments

Comments
 (0)