[PATCH 2/5] RDMA/siw: Ensure siw_destroy_cpulist can be called more than once

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In case siw module can't be inserted successfully, then if remove
the module from kernel, then both siw_cm_exit and the failure path
in siw_init_module call siw_destroy_cpulist. Let's set tx_valid_cpus
and num_nodes to prevent double free issues.

[   32.197293] general protection fault, probably for non-canonical address 0xb4965e5a58a488: 0000 [#1] PREEMPT SMP NOPTI
[   32.197300] CPU: 0 PID: 1676 Comm: modprobe Tainted: G           OE      6.5.0-rc3+ #16
[   32.197304] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.0-0-gd239552c-rebuilt.opensuse.org 04/01/2014
[   32.197306] RIP: 0010:kfree+0x62/0x150
...
[   32.197339] Call Trace:
[   32.197341]  <TASK>
[   32.197343]  ? show_regs+0x72/0x90
[   32.197348]  ? die_addr+0x38/0xb0
[   32.197351]  ? exc_general_protection+0x1bf/0x4a0
[   32.197357]  ? asm_exc_general_protection+0x27/0x30
[   32.197362]  ? kfree+0x62/0x150
[   32.197366]  siw_exit_module+0xb8/0x590 [siw]
[   32.197376]  __do_sys_delete_module.constprop.0+0x18f/0x300

So let's set tx_valid_cpus and num_nodes to prevent the issue.

Signed-off-by: Guoqing Jiang <guoqing.jiang@xxxxxxxxx>
---
 drivers/infiniband/sw/siw/siw_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/infiniband/sw/siw/siw_main.c b/drivers/infiniband/sw/siw/siw_main.c
index 65b5cda5457b..b3547253c099 100644
--- a/drivers/infiniband/sw/siw/siw_main.c
+++ b/drivers/infiniband/sw/siw/siw_main.c
@@ -178,6 +178,8 @@ static void siw_destroy_cpulist(void)
 		kfree(siw_cpu_info.tx_valid_cpus[i++]);
 
 	kfree(siw_cpu_info.tx_valid_cpus);
+	siw_cpu_info.tx_valid_cpus = NULL;
+	siw_cpu_info.num_nodes = 0;
 }
 
 /*
-- 
2.34.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux