Commit 31a99443 authored by Cristina Moraru's avatar Cristina Moraru Committed by Greg Kroah-Hartman

staging: iio: adis16060_core: Fix error handling

We need to check adis16060_spi_read return code to avoid feeding user
space with bogus data.
While, at it introduce out_unlock label in order to simplify locking
on error path.
Signed-off-by: default avatarCristina Moraru <cristina.moraru09@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1c58f0eb
......@@ -89,11 +89,13 @@ static int adis16060_read_raw(struct iio_dev *indio_dev,
/* Take the iio_dev status lock */
mutex_lock(&indio_dev->mlock);
ret = adis16060_spi_write(indio_dev, chan->address);
if (ret < 0) {
mutex_unlock(&indio_dev->mlock);
return ret;
}
if (ret < 0)
goto out_unlock;
ret = adis16060_spi_read(indio_dev, &tval);
if (ret < 0)
goto out_unlock;
mutex_unlock(&indio_dev->mlock);
*val = tval;
return IIO_VAL_INT;
......@@ -108,6 +110,10 @@ static int adis16060_read_raw(struct iio_dev *indio_dev,
}
return -EINVAL;
out_unlock:
mutex_unlock(&indio_dev->mlock);
return ret;
}
static const struct iio_info adis16060_info = {
......
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