Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 81c74136 authored by Satoru Moriya's avatar Satoru Moriya Committed by Rusty Russell
Browse files

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: default avatarSatoru Moriya <satoru.moriya@hds.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 6d6be43d
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -225,8 +225,8 @@ int parse_args(const char *name,
		int ret;						\
		int ret;						\
									\
									\
		ret = strtolfn(val, 0, &l);				\
		ret = strtolfn(val, 0, &l);				\
		if (ret == -EINVAL || ((type)l != l))			\
		if (ret < 0 || ((type)l != l))				\
			return -EINVAL;					\
			return ret < 0 ? ret : -EINVAL;			\
		*((type *)kp->arg) = l;					\
		*((type *)kp->arg) = l;					\
		return 0;						\
		return 0;						\
	}								\
	}								\