[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <e437e728317b6a2a860f7812f64a98146a27965e.1695844349.git.jahau@rocketmail.com>
Date: Wed, 27 Sep 2023 22:26:00 +0200
From: Jakob Hauser <jahau@...ketmail.com>
To: Sebastian Reichel <sre@...nel.org>
Cc: Lee Jones <lee@...nel.org>,
Stephen Rothwell <sfr@...b.auug.org.au>,
Yang Yingliang <yangyingliang@...wei.com>,
Christophe Jaillet <christophe.jaillet@...adoo.fr>,
Stephan Gerhold <stephan@...hold.net>,
Raymond Hackley <raymondhackley@...tonmail.com>,
Henrik Grimler <henrik@...mler.se>, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org,
~postmarketos/upstreaming@...ts.sr.ht,
Jakob Hauser <jahau@...ketmail.com>
Subject: [PATCH 3/5] power: supply: rt5033_charger: fix missing unlock
From: Yang Yingliang <yangyingliang@...wei.com>
Fix missing mutex_unlock() in some error path.
Fixes: 12cc585f36b8 ("power: supply: rt5033_charger: Add cable detection and USB OTG supply")
Signed-off-by: Yang Yingliang <yangyingliang@...wei.com>
Signed-off-by: Jakob Hauser <jahau@...ketmail.com>
---
drivers/power/supply/rt5033_charger.c | 28 ++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/drivers/power/supply/rt5033_charger.c b/drivers/power/supply/rt5033_charger.c
index 2c2073b8979d..091ca4a21f29 100644
--- a/drivers/power/supply/rt5033_charger.c
+++ b/drivers/power/supply/rt5033_charger.c
@@ -361,7 +361,8 @@ static int rt5033_charger_set_otg(struct rt5033_charger *charger)
0x37 << RT5033_CHGCTRL2_CV_SHIFT);
if (ret) {
dev_err(charger->dev, "Failed set OTG boost v_out\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto out_unlock;
}
/* Set operation mode to OTG */
@@ -369,7 +370,8 @@ static int rt5033_charger_set_otg(struct rt5033_charger *charger)
RT5033_CHGCTRL1_MODE_MASK, RT5033_BOOST_MODE);
if (ret) {
dev_err(charger->dev, "Failed to update OTG mode.\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto out_unlock;
}
/* In case someone switched from charging to OTG directly */
@@ -378,9 +380,10 @@ static int rt5033_charger_set_otg(struct rt5033_charger *charger)
charger->otg = true;
+out_unlock:
mutex_unlock(&charger->lock);
- return 0;
+ return ret;
}
static int rt5033_charger_unset_otg(struct rt5033_charger *charger)
@@ -420,8 +423,10 @@ static int rt5033_charger_set_charging(struct rt5033_charger *charger)
/* In case someone switched from OTG to charging directly */
if (charger->otg) {
ret = rt5033_charger_unset_otg(charger);
- if (ret)
+ if (ret) {
+ mutex_unlock(&charger->lock);
return -EINVAL;
+ }
}
charger->online = true;
@@ -448,6 +453,7 @@ static int rt5033_charger_set_mivr(struct rt5033_charger *charger)
RT5033_CHGCTRL4_MIVR_MASK, RT5033_CHARGER_MIVR_4600MV);
if (ret) {
dev_err(charger->dev, "Failed to set MIVR level.\n");
+ mutex_unlock(&charger->lock);
return -EINVAL;
}
@@ -463,7 +469,7 @@ static int rt5033_charger_set_mivr(struct rt5033_charger *charger)
static int rt5033_charger_set_disconnect(struct rt5033_charger *charger)
{
- int ret;
+ int ret = 0;
mutex_lock(&charger->lock);
@@ -475,7 +481,8 @@ static int rt5033_charger_set_disconnect(struct rt5033_charger *charger)
RT5033_CHARGER_MIVR_DISABLE);
if (ret) {
dev_err(charger->dev, "Failed to disable MIVR.\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto out_unlock;
}
charger->mivr_enabled = false;
@@ -483,16 +490,19 @@ static int rt5033_charger_set_disconnect(struct rt5033_charger *charger)
if (charger->otg) {
ret = rt5033_charger_unset_otg(charger);
- if (ret)
- return -EINVAL;
+ if (ret) {
+ ret = -EINVAL;
+ goto out_unlock;
+ }
}
if (charger->online)
charger->online = false;
+out_unlock:
mutex_unlock(&charger->lock);
- return 0;
+ return ret;
}
static enum power_supply_property rt5033_charger_props[] = {
--
2.39.2
Powered by blists - more mailing lists