hwmon: (aht10) Unlock on error in aht10_read_values()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 27 Jan 2021 05:25:26 +0000 (08:25 +0300)
committerGuenter Roeck <linux@roeck-us.net>
Thu, 28 Jan 2021 01:44:19 +0000 (17:44 -0800)
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>
Link: https://lore.kernel.org/r/YBD5Ro549hMJSnW4@mwanda
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/aht10.c

index c70d8c2d0c1fd1ca1dbaf15dbd1444aeb876da4e..2d9770cb4401b75daed15c9f4d18a27bce29db54 100644 (file)
@@ -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);