iio: dac: ad5592r: fix unbalanced mutex unlocks in ad5592r_read_raw()
authorAlexandru Ardelean <alexandru.ardelean@analog.com>
Mon, 6 Jul 2020 11:02:57 +0000 (14:02 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 22 Jul 2020 13:51:54 +0000 (14:51 +0100)
There are 2 exit paths where the lock isn't held, but try to unlock the
mutex when exiting. In these places we should just return from the
function.

A neater approach would be to cleanup the ad5592r_read_raw(), but that
would make this patch more difficult to backport to stable versions.

Fixes 56ca9db862bf3: ("iio: dac: Add support for the AD5592R/AD5593R ADCs/DACs")
Reported-by: Charles Stanhope <charles.stanhope@gmail.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/dac/ad5592r-base.c

index 5c4e5ff70380e12d59685e20515207cb0e848598..cc4875660a69f4889233eb7ae6346221592913cb 100644 (file)
@@ -413,7 +413,7 @@ static int ad5592r_read_raw(struct iio_dev *iio_dev,
                        s64 tmp = *val * (3767897513LL / 25LL);
                        *val = div_s64_rem(tmp, 1000000000LL, val2);
 
-                       ret = IIO_VAL_INT_PLUS_MICRO;
+                       return IIO_VAL_INT_PLUS_MICRO;
                } else {
                        int mult;
 
@@ -444,7 +444,7 @@ static int ad5592r_read_raw(struct iio_dev *iio_dev,
                ret =  IIO_VAL_INT;
                break;
        default:
-               ret = -EINVAL;
+               return -EINVAL;
        }
 
 unlock: