From a7b0b3ebc2af634c4e93fa3cfe8f06158c77a8f8 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Thu, 4 Jun 2026 14:18:34 -0500 Subject: [PATCH] linuxkm/module_hooks.c: tweak wc_linuxkm_malloc_usable_size() and my_kallsyms_lookup_name(), moving wc_linuxkm_can_block() to where it's really needed in my_kallsyms_lookup_name(). --- linuxkm/module_hooks.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/linuxkm/module_hooks.c b/linuxkm/module_hooks.c index e5b94ba278..88a1e97d8d 100644 --- a/linuxkm/module_hooks.c +++ b/linuxkm/module_hooks.c @@ -1325,13 +1325,11 @@ size_t wc_linuxkm_malloc_usable_size(void *ptr) #ifdef CONFIG_HAVE_KPROBES static typeof(find_vm_area) *find_vm_area_ptr = NULL; if (find_vm_area_ptr == NULL) { - if (! wc_linuxkm_can_block()) - return 0; find_vm_area_ptr = my_kallsyms_lookup_name("find_vm_area"); + if (find_vm_area_ptr == NULL) + return 0; } - if (find_vm_area_ptr == NULL) - return 0; - else if (ptr == NULL) + if (ptr == NULL) return 0; else { struct vm_struct *vm = find_vm_area_ptr(ptr); @@ -1950,6 +1948,10 @@ static WC_MAYBE_UNUSED void *my_kallsyms_lookup_name(const char *name) { if (! kallsyms_lookup_name_ptr) { int ret; + + if (! wc_linuxkm_can_block()) + return NULL; + kallsyms_lookup_name_kp.addr = NULL; if ((ret = register_kprobe(&kallsyms_lookup_name_kp)) != 0) { #ifdef WOLFSSL_LINUXKM_VERBOSE_DEBUG