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

Commit ab541631 authored by Song Hongyan's avatar Song Hongyan Committed by Jonathan Cameron
Browse files

iio: hid-sensor-attributes: Check sample_frequency/hysteresis write data legitimacy



Neither sample frequency value nor hysteresis value can be set to be a
negative number, check and return "Invalid argument" if they are negative.

If not do this change, sample_frequency will be set into some unknown
value, read hysteresis value after write negative number will return
"Invalid argument".

Signed-off-by: default avatarSong Hongyan <hongyan.song@intel.com>
Acked-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 43a07e48
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st,
	int ret;

	if (val1 < 0 || val2 < 0)
		ret = -EINVAL;
		return -EINVAL;

	value = val1 * pow_10(6) + val2;
	if (value) {
@@ -250,6 +250,9 @@ int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
	s32 value;
	int ret;

	if (val1 < 0 || val2 < 0)
		return -EINVAL;

	value = convert_to_vtf_format(st->sensitivity.size,
				st->sensitivity.unit_expo,
				val1, val2);