diff options
author | Alexey Khoroshilov <khoroshilov@ispras.ru> | 2017-05-26 18:53:04 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2017-05-28 10:45:46 -0400 |
commit | 95264c8c6a9040e84edda883dbbe9d193c41f46c (patch) | |
tree | 2b8d34342f67f0408c0775a49da54c9460e6be90 | |
parent | 3d51b956267343a65498704ada854c33c0f5e946 (diff) |
staging: iio: ad7152: Fix deadlock in ad7152_write_raw_samp_freq()
ad7152_write_raw_samp_freq() is called by ad7152_write_raw() with
chip->state_lock held. So, there is unavoidable deadlock when
ad7152_write_raw_samp_freq() locks the mutex itself.
The patch removes unneeded locking.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Fixes: 6572389bcc11 ("staging: iio: cdc: ad7152: Implement
IIO_CHAN_INFO_SAMP_FREQ attribute")
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r-- | drivers/staging/iio/cdc/ad7152.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/drivers/staging/iio/cdc/ad7152.c b/drivers/staging/iio/cdc/ad7152.c index dc6ecd824365..ff10d1f0a7e4 100644 --- a/drivers/staging/iio/cdc/ad7152.c +++ b/drivers/staging/iio/cdc/ad7152.c | |||
@@ -231,16 +231,12 @@ static int ad7152_write_raw_samp_freq(struct device *dev, int val) | |||
231 | if (i >= ARRAY_SIZE(ad7152_filter_rate_table)) | 231 | if (i >= ARRAY_SIZE(ad7152_filter_rate_table)) |
232 | i = ARRAY_SIZE(ad7152_filter_rate_table) - 1; | 232 | i = ARRAY_SIZE(ad7152_filter_rate_table) - 1; |
233 | 233 | ||
234 | mutex_lock(&chip->state_lock); | ||
235 | ret = i2c_smbus_write_byte_data(chip->client, | 234 | ret = i2c_smbus_write_byte_data(chip->client, |
236 | AD7152_REG_CFG2, AD7152_CFG2_OSR(i)); | 235 | AD7152_REG_CFG2, AD7152_CFG2_OSR(i)); |
237 | if (ret < 0) { | 236 | if (ret < 0) |
238 | mutex_unlock(&chip->state_lock); | ||
239 | return ret; | 237 | return ret; |
240 | } | ||
241 | 238 | ||
242 | chip->filter_rate_setup = i; | 239 | chip->filter_rate_setup = i; |
243 | mutex_unlock(&chip->state_lock); | ||
244 | 240 | ||
245 | return ret; | 241 | return ret; |
246 | } | 242 | } |