riscv: Correctly free relocation hashtable on error
authorCharlie Jenkins <charlie@rivosinc.com>
Thu, 4 Jan 2024 19:42:48 +0000 (11:42 -0800)
committerPalmer Dabbelt <palmer@rivosinc.com>
Wed, 10 Jan 2024 14:48:12 +0000 (06:48 -0800)
commit4b38b36bfbd83b23e20c172d08dd85773791e3bd
treeb4320bf13eac15243f4e0a99d417590e9e83d9d2
parent78996eee79ebdfe8b6f0e54cb6dcc792d5129291
riscv: Correctly free relocation hashtable on error

When there is not enough allocatable memory for the relocation
hashtable, module loading should exit gracefully. Previously, this was
attempted to be accomplished by checking if an unsigned number is less
than zero which does not work. Instead have the caller check if the
hashtable was correctly allocated and add a comment explaining that
hashtable_bits that is 0 is valid.

Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Fixes: d8792a5734b0 ("riscv: Safely remove entries from relocation list")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202312132019.iYGTwW0L-lkp@intel.com/
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@inria.fr>
Closes: https://lore.kernel.org/r/202312120044.wTI1Uyaa-lkp@intel.com/
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/20240104-module_loading_fix-v3-2-a71f8de6ce0f@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/kernel/module.c