lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <d3eb142b-eabf-4176-8a5c-0d589060abe8@web.de>
Date: Tue, 24 Sep 2024 13:00:16 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: linux-pm@...r.kernel.org,
 Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>,
 Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
 Pavel Machek <pavel@....cz>, Sebastian Reichel <sre@...nel.org>
Cc: LKML <linux-kernel@...r.kernel.org>, kernel-janitors@...r.kernel.org
Subject: [PATCH] power: supply: 88pm860x: Use common error handling code in
 set_charging_fsm()

From: Markus Elfring <elfring@...rs.sourceforge.net>
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@...rs.sourceforge.net>
---
 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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ