From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> Date: Tue, 24 Sep 2024 12:50:09 +0200 Add a jump target so that a bit of exception handling can be better reused at the end of this function implementation. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> --- drivers/power/supply/88pm860x_charger.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/power/supply/88pm860x_charger.c b/drivers/power/supply/88pm860x_charger.c index 2b9fcb7e71d7..4fdf62a7245e 100644 --- a/drivers/power/supply/88pm860x_charger.c +++ b/drivers/power/supply/88pm860x_charger.c @@ -295,17 +295,15 @@ static int set_charging_fsm(struct pm860x_charger_info *info) return -EINVAL; ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_VOLTAGE_NOW, &data); - if (ret) { - power_supply_put(psy); - return ret; - } + if (ret) + goto put_supply; + vbatt = data.intval / 1000; ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_PRESENT, &data); - if (ret) { - power_supply_put(psy); - return ret; - } + if (ret) + goto put_supply; + power_supply_put(psy); mutex_lock(&info->lock); @@ -391,6 +389,10 @@ static int set_charging_fsm(struct pm860x_charger_info *info) mutex_unlock(&info->lock); return 0; + +put_supply: + power_supply_put(psy); + return ret; } static irqreturn_t pm860x_charger_handler(int irq, void *data) -- 2.46.1