diff mbox series

[SRU,P,v2,2/6] UBUNTU: SAUCE: gpio: aggregator: Fix gpio_aggregator_line_alloc() checking

Message ID 5b4229d9131545668a48065acb6421e7692b0273.1744694723.git.koichiro.den@canonical.com
State New
Headers show
Series Introduce configfs-based interface for gpio-aggregator (LP: #2103496) | expand

Commit Message

Koichiro Den April 15, 2025, 6:13 a.m. UTC
From: Dan Carpenter <dan.carpenter@linaro.org>

BugLink: https://bugs.launchpad.net/bugs/2103496

The gpio_aggregator_line_alloc() function returns error pointers, but
the callers check for NULL.  Update the error checking in the callers.

Fixes: 83c8e3df642f ("gpio: aggregator: expose aggregator created via legacy sysfs to configfs")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Koichiro Den <koichiro.den@canonical.com>
Link: https://lore.kernel.org/r/cc71d8cf6e9bb4bb8cd9ae5050100081891d9345.1744452787.git.dan.carpenter@linaro.org
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
(backported from commit 2e8636ca340002f3ac31383622911a1aa75fb086 gpio/for-next)
[koichiroden: adjusted context because Plucky already includes v6 patch
series, where relevant functions naming differs from v7]
Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
---
 drivers/gpio/gpio-aggregator.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c
index ac84f171dfba..b31dfcfeb074 100644
--- a/drivers/gpio/gpio-aggregator.c
+++ b/drivers/gpio/gpio-aggregator.c
@@ -970,8 +970,8 @@  gpio_aggr_device_make_group(struct config_group *group, const char *name)
 			return ERR_PTR(-EINVAL);
 
 	line = aggr_line_alloc(aggr, idx, NULL, -1);
-	if (!line)
-		return ERR_PTR(-ENOMEM);
+	if (IS_ERR(line))
+		return ERR_CAST(line);
 
 	config_group_init_type_name(&line->group, name, &gpio_aggr_line_type);
 
@@ -1061,8 +1061,8 @@  static int aggr_parse(struct gpio_aggregator *aggr)
 			/* Named GPIO line */
 			scnprintf(name, sizeof(name), "line%u", n);
 			line = aggr_line_alloc(aggr, n, key, -1);
-			if (!line) {
-				error = -ENOMEM;
+			if (IS_ERR(line)) {
+				error = PTR_ERR(line);
 				goto err;
 			}
 			config_group_init_type_name(&line->group, name,
@@ -1092,8 +1092,8 @@  static int aggr_parse(struct gpio_aggregator *aggr)
 		for_each_set_bit(i, bitmap, AGGREGATOR_MAX_GPIOS) {
 			scnprintf(name, sizeof(name), "line%u", n);
 			line = aggr_line_alloc(aggr, n, key, i);
-			if (!line) {
-				error = -ENOMEM;
+			if (IS_ERR(line)) {
+				error = PTR_ERR(line);
 				goto err;
 			}
 			config_group_init_type_name(&line->group, name,