* [PATCH -next] power: supply: bq25890_charger: fix missing unlock on error in bq25890_resume()
@ 2020-05-06 1:40 Wei Yongjun
2020-05-06 12:25 ` Michał Mirosław
0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2020-05-06 1:40 UTC (permalink / raw)
To: Sebastian Reichel, Micha Mirosaw; +Cc: Wei Yongjun, linux-pm, kernel-janitors
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(-)
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 */
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next] power: supply: bq25890_charger: fix missing unlock on error in bq25890_resume()
2020-05-06 1:40 [PATCH -next] power: supply: bq25890_charger: fix missing unlock on error in bq25890_resume() Wei Yongjun
@ 2020-05-06 12:25 ` Michał Mirosław
0 siblings, 0 replies; 2+ messages in thread
From: Michał Mirosław @ 2020-05-06 12:25 UTC (permalink / raw)
To: Wei Yongjun; +Cc: Sebastian Reichel, Dan Carpenter, linux-pm, kernel-janitors
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 */
>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-06 12:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-06 1:40 [PATCH -next] power: supply: bq25890_charger: fix missing unlock on error in bq25890_resume() Wei Yongjun
2020-05-06 12:25 ` Michał Mirosław
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).