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:
 [<ffffffff812b868e>] dump_stack+0x52/0x84
 [<ffffffff8105cb55>] warn_slowpath_common+0x95/0xe0
 [<ffffffff8105cbba>] warn_slowpath_null+0x1a/0x20
 [<ffffffffa03bd8d1>] cpumask_check+0x31/0x40 [scst]
 [<ffffffffa03bd8f1>] cpumask_test_cpu+0x11/0x30 [scst]
 [<ffffffffa03c073f>] scst_sgv_pools_init+0x18f/0x410 [scst]
 [<ffffffff815ca2d5>] ? _raw_spin_unlock+0x35/0x60
 [<ffffffff81206cd5>] ? nr_blockdev_pages+0x65/0x70
 [<ffffffffa0791b64>] init_scst+0xa4c/0xce6 [scst]
 [<ffffffff8100035e>] ? do_one_initcall+0x9e/0x1d0
 [<ffffffff810b4fd0>] ? trace_hardirqs_on_caller+0x100/0x1c0
 [<ffffffff810b509d>] ? trace_hardirqs_on+0xd/0x10
 [<ffffffffa0791118>] ? scst_print_config+0x118/0x118 [scst]
 [<ffffffff8100036d>] do_one_initcall+0xad/0x1d0
 [<ffffffff810f99fa>] do_init_module+0x6a/0x210
 [<ffffffff810fc491>] load_module+0x551/0x750
 [<ffffffff810f8950>] ? mod_sysfs_teardown+0x140/0x140
 [<ffffffff810f8400>] ? module_sect_show+0x30/0x30
 [<ffffffff810f8a33>] ? copy_chunked_from_user+0x63/0xa0
 [<ffffffff810fc85f>] SyS_init_module+0xdf/0x120
 [<ffffffff815ca6f2>] entry_SYSCALL_64_fastpath+0x12/0x76


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8162 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2019-04-06 23:15:57 +00:00
parent 976595dccb
commit 1c75b0fd84

View File

@@ -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);