Skip to contentSkip to conversation

power: bq25890: unlock on error paths in bq25890_resume()

PATCH In review Dan Carpenter 3 participants 3 messages May 6, 2020 – May 9, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 power: bq25890: unlock on error paths in bq25890_resume()

We introduced some new locking here, but need to update the error paths so they unlock before returning.

Fixes 72d9cd9cdc18 ("power: bq25890: protect view of the chip's state")
---
 drivers/power/supply/bq25890_charger.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/power/supply/bq25890_charger.c +4 -3
index 9339e216651ff..20b9824ef5acd 100644
@@ -978,21 +978,22 @@ static int bq25890_resume(struct device *dev)
 
 	ret = bq25890_get_chip_state(bq, &bq->state);
 	if (ret < 0)
-		return ret;
+		goto unlock;
 
 	/* 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)
-			return ret;
+			goto unlock;
 	}
 
 	/* signal userspace, maybe state changed while suspended */
 	power_supply_changed(bq->charger);
 
+unlock:
 	mutex_unlock(&bq->lock);
 
-	return 0;
+	return ret;
 }
 #endif
 
Signature · 1 line
2.26.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Dan Carpenter

We introduced some new locking here, but need to update the error paths so they unlock before returning.

Quoted 39 lines
Fixes 72d9cd9cdc18 ("power: bq25890: protect view of the chip's state")
---
 drivers/power/supply/bq25890_charger.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/power/supply/bq25890_charger.c +4 -3
index 9339e216651ff..20b9824ef5acd 100644
@@ -978,21 +978,22 @@ static int bq25890_resume(struct device *dev)
 
 	ret = bq25890_get_chip_state(bq, &bq->state);
 	if (ret < 0)
-		return ret;
+		goto unlock;
 
 	/* 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)
-			return ret;
+			goto unlock;
 	}
 
 	/* signal userspace, maybe state changed while suspended */
 	power_supply_changed(bq->charger);
 
+unlock:
 	mutex_unlock(&bq->lock);
 
-	return 0;
+	return ret;
 }
 #endif
 
Signature · 1 line
2.26.2
#2 lore raw

Hi,

Quoted 5 lines · Michał Mirosław
Quoted 2 lines · Dan Carpenter

We introduced some new locking here, but need to update the error paths so they unlock before returning.

Thanks, queued.

-- Sebastian

Quoted 39 lines
Quoted 39 lines
Fixes 72d9cd9cdc18 ("power: bq25890: protect view of the chip's state")
---
 drivers/power/supply/bq25890_charger.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/power/supply/bq25890_charger.c +4 -3
index 9339e216651ff..20b9824ef5acd 100644
@@ -978,21 +978,22 @@ static int bq25890_resume(struct device *dev)
 
 	ret = bq25890_get_chip_state(bq, &bq->state);
 	if (ret < 0)
-		return ret;
+		goto unlock;
 
 	/* 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)
-			return ret;
+			goto unlock;
 	}
 
 	/* signal userspace, maybe state changed while suspended */
 	power_supply_changed(bq->charger);
 
+unlock:
 	mutex_unlock(&bq->lock);
 
-	return 0;
+	return ret;
 }
 #endif
 
Signature · 1 line
2.26.2