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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 30 Aug 2023 23:38:54 +0200
From:   Michał Mirosław <mirq-linux@...e.qmqm.pl>
To:     Liam Girdwood <lgirdwood@...il.com>,
        Mark Brown <broonie@...nel.org>
Cc:     linux-kernel@...r.kernel.org
Subject: [PATCH 1/9] regulator/core: _regulator_get: simplify error returns

Remove unnecessary stores to `regulator`.

Signed-off-by: Michał Mirosław <mirq-linux@...e.qmqm.pl>
---
 drivers/regulator/core.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 662711063433..d440cd137c38 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2209,15 +2209,13 @@ struct regulator *_regulator_get(struct device *dev, const char *id,
 	}
 
 	if (rdev->exclusive) {
-		regulator = ERR_PTR(-EPERM);
 		put_device(&rdev->dev);
-		return regulator;
+		return ERR_PTR(-EPERM);
 	}
 
 	if (get_type == EXCLUSIVE_GET && rdev->open_count) {
-		regulator = ERR_PTR(-EBUSY);
 		put_device(&rdev->dev);
-		return regulator;
+		return ERR_PTR(-EBUSY);
 	}
 
 	mutex_lock(&regulator_list_mutex);
@@ -2225,32 +2223,28 @@ struct regulator *_regulator_get(struct device *dev, const char *id,
 	mutex_unlock(&regulator_list_mutex);
 
 	if (ret != 0) {
-		regulator = ERR_PTR(-EPROBE_DEFER);
 		put_device(&rdev->dev);
-		return regulator;
+		return ERR_PTR(-EPROBE_DEFER);
 	}
 
 	ret = regulator_resolve_supply(rdev);
 	if (ret < 0) {
-		regulator = ERR_PTR(ret);
 		put_device(&rdev->dev);
-		return regulator;
+		return ERR_PTR(ret);
 	}
 
 	if (!try_module_get(rdev->owner)) {
-		regulator = ERR_PTR(-EPROBE_DEFER);
 		put_device(&rdev->dev);
-		return regulator;
+		return ERR_PTR(-EPROBE_DEFER);
 	}
 
 	regulator_lock(rdev);
 	regulator = create_regulator(rdev, dev, id);
 	regulator_unlock(rdev);
 	if (regulator == NULL) {
-		regulator = ERR_PTR(-ENOMEM);
 		module_put(rdev->owner);
 		put_device(&rdev->dev);
-		return regulator;
+		return ERR_PTR(-ENOMEM);
 	}
 
 	rdev->open_count++;
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ