Skip to content

Commit 78996ee

Browse files
charlie-rivospalmer-dabbelt
authored andcommitted
riscv: Fix module loading free order
Reverse order of kfree calls to resolve use-after-free error. Signed-off-by: Charlie Jenkins <[email protected]> Fixes: d8792a5 ("riscv: Safely remove entries from relocation list") Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/r/[email protected]/ Reported-by: kernel test robot <[email protected]> Reported-by: Julia Lawall <[email protected]> Closes: https://lore.kernel.org/r/[email protected]/ Reviewed-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent ed5b7cf commit 78996ee

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/riscv/kernel/module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,8 @@ static int add_relocation_to_accumulate(struct module *me, int type,
723723

724724
if (!bucket) {
725725
kfree(entry);
726-
kfree(rel_head);
727726
kfree(rel_head->rel_entry);
727+
kfree(rel_head);
728728
return -ENOMEM;
729729
}
730730

0 commit comments

Comments
 (0)