Unverified Commit 8578b2f7 authored by Will Pierce's avatar Will Pierce Committed by Alexandre Ghiti
Browse files

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: 8fd6c514 ("riscv: Add remaining module relocations")
Suggested-by: default avatarClément Léger <cleger@rivosinc.com>
Reviewed-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: default avatarWill Pierce <wgpierce17@gmail.com>
Link: https://lore.kernel.org/r/20250402081426.5197-1-wgpierce17@gmail.com


Signed-off-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
parent 0af2f6be
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -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,7 +752,8 @@ initialize_relocation_hashtable(unsigned int num_relocations,

	hashtable_size <<= should_double_size;

	*relocation_hashtable = kmalloc_array(hashtable_size,
	/* Number of relocations may be large, so kvmalloc it */
	*relocation_hashtable = kvmalloc_array(hashtable_size,
					       sizeof(**relocation_hashtable),
					       GFP_KERNEL);
	if (!*relocation_hashtable)