diff mbox series

[-next] power: supply: bq25890_charger: fix missing unlock on error in bq25890_resume()

Message ID 20200506014008.59755-1-weiyongjun1@huawei.com (mailing list archive)
State Not Applicable, archived
Headers show
Series [-next] power: supply: bq25890_charger: fix missing unlock on error in bq25890_resume() | expand

Commit Message

weiyongjun (A) May 6, 2020, 1:40 a.m. UTC
Add the missing unlock before return from function bq25890_resume()
in the error handling case.

Fixes: 72d9cd9cdc18 ("power: bq25890: protect view of the chip's state")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/power/supply/bq25890_charger.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Michał Mirosław May 6, 2020, 12:25 p.m. UTC | #1
On Wed, May 06, 2020 at 01:40:08AM +0000, Wei Yongjun wrote:
> Add the missing unlock before return from function bq25890_resume()
> in the error handling case.
> 
> Fixes: 72d9cd9cdc18 ("power: bq25890: protect view of the chip's state")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

A similar fix was sent by Dan Carpenter [1]. I'd prefer his version due
to less lines introduced.

[1] https://lore.kernel.org/linux-pm/20200506101116.GA77004@mwanda/

Best Regards,
Michał Mirosław

> ---
>  drivers/power/supply/bq25890_charger.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
> index 9339e216651f..cd9c5ed9bc0c 100644
> --- a/drivers/power/supply/bq25890_charger.c
> +++ b/drivers/power/supply/bq25890_charger.c
> @@ -977,14 +977,18 @@ static int bq25890_resume(struct device *dev)
>  	mutex_lock(&bq->lock);
>  
>  	ret = bq25890_get_chip_state(bq, &bq->state);
> -	if (ret < 0)
> +	if (ret < 0) {
> +		mutex_unlock(&bq->lock);
>  		return ret;
> +	}
>  
>  	/* Re-enable ADC only if charger is plugged in. */
>  	if (bq->state.online) {
>  		ret = bq25890_field_write(bq, F_CONV_START, 1);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			mutex_unlock(&bq->lock);
>  			return ret;
> +		}
>  	}
>  
>  	/* signal userspace, maybe state changed while suspended */
> 
> 
>
diff mbox series

Patch

diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
index 9339e216651f..cd9c5ed9bc0c 100644
--- a/drivers/power/supply/bq25890_charger.c
+++ b/drivers/power/supply/bq25890_charger.c
@@ -977,14 +977,18 @@  static int bq25890_resume(struct device *dev)
 	mutex_lock(&bq->lock);
 
 	ret = bq25890_get_chip_state(bq, &bq->state);
-	if (ret < 0)
+	if (ret < 0) {
+		mutex_unlock(&bq->lock);
 		return ret;
+	}
 
 	/* Re-enable ADC only if charger is plugged in. */
 	if (bq->state.online) {
 		ret = bq25890_field_write(bq, F_CONV_START, 1);
-		if (ret < 0)
+		if (ret < 0) {
+			mutex_unlock(&bq->lock);
 			return ret;
+		}
 	}
 
 	/* signal userspace, maybe state changed while suspended */