aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharlie Jenkins <[email protected]>2024-01-04 11:42:47 -0800
committerPalmer Dabbelt <[email protected]>2024-01-10 06:48:11 -0800
commit78996eee79ebdfe8b6f0e54cb6dcc792d5129291 (patch)
treebf943ffa12163a045b9b57ef6a1b2649faf9e5d6
parented5b7cfd7839f9280a63365c1133482b42d0981f (diff)
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: d8792a5734b0 ("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]>
-rw-r--r--arch/riscv/kernel/module.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c
index aac019ed63b1..21c7a773a8ef 100644
--- a/arch/riscv/kernel/module.c
+++ b/arch/riscv/kernel/module.c
@@ -723,8 +723,8 @@ static int add_relocation_to_accumulate(struct module *me, int type,
if (!bucket) {
kfree(entry);
- kfree(rel_head);
kfree(rel_head->rel_entry);
+ kfree(rel_head);
return -ENOMEM;
}