Thread (65 messages) 65 messages, 12 authors, 2023-07-17

Re: [PATCH v2 01/12] nios2: define virtual address space for modules

From: Mike Rapoport <rppt@kernel.org>
Date: 2023-06-17 05:53:49
Also in: bpf, linux-mips, linux-mm, linux-modules, linux-riscv, linux-s390, linux-trace-kernel, linuxppc-dev, lkml, loongarch, netdev, sparclinux

On Fri, Jun 16, 2023 at 04:00:19PM +0000, Edgecombe, Rick P wrote:
On Fri, 2023-06-16 at 11:50 +0300, Mike Rapoport wrote:
quoted
 void *module_alloc(unsigned long size)
 {
-       if (size == 0)
-               return NULL;
-       return kmalloc(size, GFP_KERNEL);
-}
-
-/* Free memory returned from module_alloc */
-void module_memfree(void *module_region)
-{
-       kfree(module_region);
+       return __vmalloc_node_range(size, 1, MODULES_VADDR,
MODULES_END,
+                                   GFP_KERNEL, PAGE_KERNEL_EXEC,
+                                   VM_FLUSH_RESET_PERMS,
NUMA_NO_NODE,
+                                   __builtin_return_address(0));
 }
 
 int apply_relocate_add(Elf32_Shdr *sechdrs, const char *s
I wonder if the (size == 0) check is really needed, but
__vmalloc_node_range() will WARN on this case where the old code won't.
module_alloc() should not be called with zero size, so a warning there
would be appropriate.
Besides, no other module_alloc() had this check.

-- 
Sincerely yours,
Mike.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help