diff options
author | Guoqing Jiang <guoqing.jiang@linux.dev> | 2023-11-13 19:57:18 +0800 |
---|---|---|
committer | Leon Romanovsky <leon@kernel.org> | 2023-11-15 15:58:13 +0200 |
commit | 25680c1f2614756463040f2dc03b3ec611ae3bfe (patch) | |
tree | c3501944796b406a24934d6b519af1b6c233e37d | |
parent | 6a343cc3bf2626bc0c487bf2a72c90b4519c3da4 (diff) | |
download | linux-stable-25680c1f2614756463040f2dc03b3ec611ae3bfe.tar.gz linux-stable-25680c1f2614756463040f2dc03b3ec611ae3bfe.tar.bz2 linux-stable-25680c1f2614756463040f2dc03b3ec611ae3bfe.zip |
RDMA/siw: Add one parameter to siw_destroy_cpulist
With that we can reuse it in siw_init_cpulist.
Acked-by: Bernard Metzler <bmt@zurich.ibm.com>
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
Link: https://lore.kernel.org/r/20231113115726.12762-10-guoqing.jiang@linux.dev
Signed-off-by: Leon Romanovsky <leon@kernel.org>
-rw-r--r-- | drivers/infiniband/sw/siw/siw_main.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/drivers/infiniband/sw/siw/siw_main.c b/drivers/infiniband/sw/siw/siw_main.c index 1ab62982df74..61ad8ca3d1a2 100644 --- a/drivers/infiniband/sw/siw/siw_main.c +++ b/drivers/infiniband/sw/siw/siw_main.c @@ -109,6 +109,17 @@ static struct { int num_nodes; } siw_cpu_info; +static void siw_destroy_cpulist(int number) +{ + int i = 0; + + while (i < number) + kfree(siw_cpu_info.tx_valid_cpus[i++]); + + kfree(siw_cpu_info.tx_valid_cpus); + siw_cpu_info.tx_valid_cpus = NULL; +} + static int siw_init_cpulist(void) { int i, num_nodes = nr_node_ids; @@ -138,24 +149,11 @@ static int siw_init_cpulist(void) out_err: siw_cpu_info.num_nodes = 0; - while (--i >= 0) - kfree(siw_cpu_info.tx_valid_cpus[i]); - kfree(siw_cpu_info.tx_valid_cpus); - siw_cpu_info.tx_valid_cpus = NULL; + siw_destroy_cpulist(i); return -ENOMEM; } -static void siw_destroy_cpulist(void) -{ - int i = 0; - - while (i < siw_cpu_info.num_nodes) - kfree(siw_cpu_info.tx_valid_cpus[i++]); - - kfree(siw_cpu_info.tx_valid_cpus); -} - /* * Choose CPU with least number of active QP's from NUMA node of * TX interface. @@ -558,7 +556,7 @@ out_error: pr_info("SoftIWARP attach failed. Error: %d\n", rv); siw_cm_exit(); - siw_destroy_cpulist(); + siw_destroy_cpulist(siw_cpu_info.num_nodes); return rv; } @@ -573,7 +571,7 @@ static void __exit siw_exit_module(void) siw_cm_exit(); - siw_destroy_cpulist(); + siw_destroy_cpulist(siw_cpu_info.num_nodes); if (siw_crypto_shash) crypto_free_shash(siw_crypto_shash); |