Skip to contentSkip to conversation

riscv: Use kvmalloc_array on relocation_hashtable

PATCH New [email protected] 1 participant 1 message Apr 2, 2025 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 riscv: Use kvmalloc_array on relocation_hashtable

From: Will Pierce <[email protected]>

The number of relocations may be a huge value that is unallocatable by kmalloc. Use kvmalloc instead so that it does not fail.

Fixes 8fd6c5142395 ("riscv: Add remaining module relocations")
---
 arch/riscv/kernel/module.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
arch/riscv/kernel/module.c +5 -4
index 47d0ebeec93c..0ae34d79b87b 100644
@@ -648,7 +648,7 @@ process_accumulated_relocations(struct module *me,
 		kfree(bucket_iter);
 	}
 
-	kfree(*relocation_hashtable);
+	kvfree(*relocation_hashtable);
 }
 
 static int add_relocation_to_accumulate(struct module *me, int type,
@@ -752,9 +752,10 @@ initialize_relocation_hashtable(unsigned int num_relocations,
 
 	hashtable_size <<= should_double_size;
 
-	*relocation_hashtable = kmalloc_array(hashtable_size,
-					      sizeof(**relocation_hashtable),
-					      GFP_KERNEL);
+	/* Number of relocations may be large, so kvmalloc it */
+	*relocation_hashtable = kvmalloc_array(hashtable_size,
+					       sizeof(**relocation_hashtable),
+					       GFP_KERNEL);
 	if (!*relocation_hashtable)
 		return 0;
 
Signature · 7 lines
2.49.0


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv