Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

param: fix return value handling in param_set_*

In STANDARD_PARAM_DEF, param_set_* handles the case in which strtolfn
returns -EINVAL but it may return -ERANGE. If it returns -ERANGE,
param_set_* may set uninitialized value to the paramerter. We should handle
both cases.

The one of the cases in which strtolfn() returns -ERANGE is following:

*Type of module parameter is long
*Set the parameter more than LONG_MAX

Signed-off-by: Satoru Moriya <satoru.moriya@hds.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

authored by

Satoru Moriya and committed by
Rusty Russell
81c74136 6d6be43d

+2 -2
+2 -2
kernel/params.c
··· 225 225 int ret; \ 226 226 \ 227 227 ret = strtolfn(val, 0, &l); \ 228 - if (ret == -EINVAL || ((type)l != l)) \ 229 - return -EINVAL; \ 228 + if (ret < 0 || ((type)l != l)) \ 229 + return ret < 0 ? ret : -EINVAL; \ 230 230 *((type *)kp->arg) = l; \ 231 231 return 0; \ 232 232 } \