From 1c75b0fd847ff4f4deaf1522d400e58b428fe605 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 6 Apr 2019 23:15:57 +0000 Subject: [PATCH] scst_mem: Avoid passing a too large value to cpus_online() This patch avoids that the following warning is reported against a debug kernel: WARNING: CPU: 0 PID: 3343 at include/linux/cpumask.h:117 cpumask_check+0x31/0x40 [scst]() CPU: 0 PID: 3343 Comm: modprobe Tainted: G O 4.3.6-dbg+ #7 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 Call Trace: [] dump_stack+0x52/0x84 [] warn_slowpath_common+0x95/0xe0 [] warn_slowpath_null+0x1a/0x20 [] cpumask_check+0x31/0x40 [scst] [] cpumask_test_cpu+0x11/0x30 [scst] [] scst_sgv_pools_init+0x18f/0x410 [scst] [] ? _raw_spin_unlock+0x35/0x60 [] ? nr_blockdev_pages+0x65/0x70 [] init_scst+0xa4c/0xce6 [scst] [] ? do_one_initcall+0x9e/0x1d0 [] ? trace_hardirqs_on_caller+0x100/0x1c0 [] ? trace_hardirqs_on+0xd/0x10 [] ? scst_print_config+0x118/0x118 [scst] [] do_one_initcall+0xad/0x1d0 [] do_init_module+0x6a/0x210 [] load_module+0x551/0x750 [] ? mod_sysfs_teardown+0x140/0x140 [] ? module_sect_show+0x30/0x30 [] ? copy_chunked_from_user+0x63/0xa0 [] SyS_init_module+0xdf/0x120 [] entry_SYSCALL_64_fastpath+0x12/0x76 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8162 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_mem.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index dc8794037..b553d4ca5 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -1775,16 +1775,16 @@ int scst_sgv_pools_init(unsigned long mem_hwmark, unsigned long mem_lwmark) * callbacks must be installed! */ - for (i = 0; i < NR_CPUS; i++) + for (i = 0; i < nr_cpu_ids; i++) sgv_norm_pool_global[i] = sgv_norm_pool_main; - for (i = 0; i < NR_CPUS; i++) + for (i = 0; i < nr_cpu_ids; i++) sgv_norm_clust_pool_global[i] = sgv_norm_clust_pool_main; - for (i = 0; i < NR_CPUS; i++) + for (i = 0; i < nr_cpu_ids; i++) sgv_dma_pool_global[i] = sgv_dma_pool_main; - for (i = 0; i < NR_CPUS; i++) { + for (i = 0; i < nr_cpu_ids; i++) { char name[60]; if (!cpu_online(i)) @@ -1796,7 +1796,7 @@ int scst_sgv_pools_init(unsigned long mem_hwmark, unsigned long mem_lwmark) goto out_free_per_cpu_norm; } - for (i = 0; i < NR_CPUS; i++) { + for (i = 0; i < nr_cpu_ids; i++) { char name[60]; if (!cpu_online(i)) @@ -1808,7 +1808,7 @@ int scst_sgv_pools_init(unsigned long mem_hwmark, unsigned long mem_lwmark) goto out_free_per_cpu_clust; } - for (i = 0; i < NR_CPUS; i++) { + for (i = 0; i < nr_cpu_ids; i++) { char name[60]; if (!cpu_online(i)) @@ -1838,17 +1838,17 @@ out: return res; out_free_per_cpu_dma: - for (i = 0; i < NR_CPUS; i++) + for (i = 0; i < nr_cpu_ids; i++) if (sgv_dma_pool_per_cpu[i] != NULL) sgv_pool_destroy(sgv_dma_pool_per_cpu[i]); out_free_per_cpu_clust: - for (i = 0; i < NR_CPUS; i++) + for (i = 0; i < nr_cpu_ids; i++) if (sgv_norm_clust_pool_per_cpu[i] != NULL) sgv_pool_destroy(sgv_norm_clust_pool_per_cpu[i]); out_free_per_cpu_norm: - for (i = 0; i < NR_CPUS; i++) + for (i = 0; i < nr_cpu_ids; i++) if (sgv_norm_pool_per_cpu[i] != NULL) sgv_pool_destroy(sgv_norm_pool_per_cpu[i]); @@ -1881,27 +1881,27 @@ void scst_sgv_pools_deinit(void) #endif sgv_pool_destroy(sgv_dma_pool_main); - for (i = 0; i < NR_CPUS; i++) + for (i = 0; i < nr_cpu_ids; i++) if (sgv_dma_pool_per_cpu[i] != NULL) sgv_pool_destroy(sgv_dma_pool_per_cpu[i]); sgv_pool_destroy(sgv_norm_pool_main); - for (i = 0; i < NR_CPUS; i++) + for (i = 0; i < nr_cpu_ids; i++) if (sgv_norm_pool_per_cpu[i] != NULL) sgv_pool_destroy(sgv_norm_pool_per_cpu[i]); sgv_pool_destroy(sgv_norm_clust_pool_main); - for (i = 0; i < NR_CPUS; i++) + for (i = 0; i < nr_cpu_ids; i++) if (sgv_norm_clust_pool_per_cpu[i] != NULL) sgv_pool_destroy(sgv_norm_clust_pool_per_cpu[i]); - for (i = 0; i < NR_CPUS; i++) + for (i = 0; i < nr_cpu_ids; i++) sgv_norm_pool_global[i] = NULL; - for (i = 0; i < NR_CPUS; i++) + for (i = 0; i < nr_cpu_ids; i++) sgv_norm_clust_pool_global[i] = NULL; - for (i = 0; i < NR_CPUS; i++) + for (i = 0; i < nr_cpu_ids; i++) sgv_dma_pool_global[i] = NULL; kmem_cache_destroy(sgv_pool_cachep);