iio: adc: meson-saradc: unlock on error in meson_sar_adc_lock()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 8 Mar 2018 09:31:53 +0000 (12:31 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 10 Mar 2018 15:14:14 +0000 (15:14 +0000)
The meson_sar_adc_lock() function is not supposed to hold the
"indio_dev->mlock" on the error path.

Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/meson_saradc.c

index 29fa7736d80caae392095123d207695cc87f53df..ede955d9b2a4d67582ab596fc48cc032dae3158b 100644 (file)
@@ -462,8 +462,10 @@ static int meson_sar_adc_lock(struct iio_dev *indio_dev)
                        regmap_read(priv->regmap, MESON_SAR_ADC_DELAY, &val);
                } while (val & MESON_SAR_ADC_DELAY_BL30_BUSY && timeout--);
 
-               if (timeout < 0)
+               if (timeout < 0) {
+                       mutex_unlock(&indio_dev->mlock);
                        return -ETIMEDOUT;
+               }
        }
 
        return 0;