Commit 4e882ddc authored by Peter Meerwald's avatar Peter Meerwald Committed by Luis Henriques

iio: tmp006: Check channel info on write

commit 8d05abfa upstream.

only SAMP_FREQ is writable

Will lead to SAMP_FREQ being written by any attempt to write
to the other exported attributes and hence a rather unexpected
result!
Signed-off-by: default avatarPeter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 2b24558c
...@@ -132,6 +132,9 @@ static int tmp006_write_raw(struct iio_dev *indio_dev, ...@@ -132,6 +132,9 @@ static int tmp006_write_raw(struct iio_dev *indio_dev,
struct tmp006_data *data = iio_priv(indio_dev); struct tmp006_data *data = iio_priv(indio_dev);
int i; int i;
if (mask != IIO_CHAN_INFO_SAMP_FREQ)
return -EINVAL;
for (i = 0; i < ARRAY_SIZE(tmp006_freqs); i++) for (i = 0; i < ARRAY_SIZE(tmp006_freqs); i++)
if ((val == tmp006_freqs[i][0]) && if ((val == tmp006_freqs[i][0]) &&
(val2 == tmp006_freqs[i][1])) { (val2 == tmp006_freqs[i][1])) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment