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: Cristina Moraru <cristina.moraru09@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
                /* 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;
        }
 
        return -EINVAL;
+
+out_unlock:
+       mutex_unlock(&indio_dev->mlock);
+       return ret;
 }
 
 static const struct iio_info adis16060_info = {