diff mbox series

hwmon: (aht10) Unlock on error in aht10_read_values()

Message ID YBD5Ro549hMJSnW4@mwanda (mailing list archive)
State Accepted
Headers show
Series hwmon: (aht10) Unlock on error in aht10_read_values() | expand

Commit Message

Dan Carpenter Jan. 27, 2021, 5:25 a.m. UTC
This error path needs to drop the lock before returning.

Fixes: afd018716398 ("hwmon: Add AHT10 Temperature and Humidity Sensor Driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/hwmon/aht10.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Guenter Roeck Jan. 27, 2021, 4:47 p.m. UTC | #1
On Wed, Jan 27, 2021 at 08:25:26AM +0300, Dan Carpenter wrote:
> This error path needs to drop the lock before returning.
> 
> Fixes: afd018716398 ("hwmon: Add AHT10 Temperature and Humidity Sensor Driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied.

Thanks,
Guenter
diff mbox series

Patch

diff --git a/drivers/hwmon/aht10.c b/drivers/hwmon/aht10.c
index c70d8c2d0c1f..2d9770cb4401 100644
--- a/drivers/hwmon/aht10.c
+++ b/drivers/hwmon/aht10.c
@@ -138,8 +138,10 @@  static int aht10_read_values(struct aht10_data *data)
 	mutex_lock(&data->lock);
 	if (aht10_polltime_expired(data)) {
 		res = i2c_master_send(client, cmd_meas, sizeof(cmd_meas));
-		if (res < 0)
+		if (res < 0) {
+			mutex_unlock(&data->lock);
 			return res;
+		}
 
 		usleep_range(AHT10_MEAS_DELAY,
 			     AHT10_MEAS_DELAY + AHT10_DELAY_EXTRA);