Commit 81c7413650fbbf881bcb9e567be61a6717eb1876

Authored by Satoru Moriya
Committed by Rusty Russell
1 parent 6d6be43d4d

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>

Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff

... ... @@ -225,8 +225,8 @@
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 } \