Skip to content

Commit 8578b2f

Browse files
Will PierceAlexandre Ghiti
authored andcommitted
riscv: Use kvmalloc_array on relocation_hashtable
The number of relocations may be a huge value that is unallocatable by kmalloc. Use kvmalloc instead so that it does not fail. Fixes: 8fd6c51 ("riscv: Add remaining module relocations") Suggested-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Signed-off-by: Will Pierce <wgpierce17@gmail.com> Link: https://lore.kernel.org/r/20250402081426.5197-1-wgpierce17@gmail.com Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
1 parent 0af2f6b commit 8578b2f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

arch/riscv/kernel/module.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ process_accumulated_relocations(struct module *me,
648648
kfree(bucket_iter);
649649
}
650650

651-
kfree(*relocation_hashtable);
651+
kvfree(*relocation_hashtable);
652652
}
653653

654654
static int add_relocation_to_accumulate(struct module *me, int type,
@@ -752,9 +752,10 @@ initialize_relocation_hashtable(unsigned int num_relocations,
752752

753753
hashtable_size <<= should_double_size;
754754

755-
*relocation_hashtable = kmalloc_array(hashtable_size,
756-
sizeof(**relocation_hashtable),
757-
GFP_KERNEL);
755+
/* Number of relocations may be large, so kvmalloc it */
756+
*relocation_hashtable = kvmalloc_array(hashtable_size,
757+
sizeof(**relocation_hashtable),
758+
GFP_KERNEL);
758759
if (!*relocation_hashtable)
759760
return 0;
760761

0 commit comments

Comments
 (0)