refscale: Bounds-check module parameters
authorPaul E. McKenney <paulmck@kernel.org>
Thu, 27 Aug 2020 16:58:19 +0000 (09:58 -0700)
committerPaul E. McKenney <paulmck@kernel.org>
Tue, 3 Nov 2020 01:13:29 +0000 (17:13 -0800)
commit0c6d18d84db11840dd0f3f65750c6ea0bb6b8e0d
treea909c61492a1834bcae501fce1abe448e3975d2c
parent3650b228f83adda7e5ee532e2b90429c03f7b9ec
refscale: Bounds-check module parameters

The default value for refscale.nreaders is -1, which results in the code
setting the value to three-quarters of the number of CPUs.  On single-CPU
systems, this results in three-quarters of the value one, which the C
language's integer arithmetic rounds to zero.  This in turn results in
a divide-by-zero error.

This commit therefore adds bounds checking to the refscale module
parameters, so that if they are less than one, they are set to the
value one.

Reported-by: kernel test robot <lkp@intel.com>
Tested-by "Chen, Rong A" <rong.a.chen@intel.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
kernel/rcu/refscale.c