[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210510095045.3299382-5-andy.shevchenko@gmail.com>
Date: Mon, 10 May 2021 12:50:21 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Pavel Machek <pavel@....cz>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Amireddy Mallikarjuna reddy
<mallikarjunax.reddy@...ux.intel.com>,
Linus Walleij <linus.walleij@...aro.org>,
Marek BehĂșn <marek.behun@....cz>,
Abanoub Sameh <abanoubsameh8@...il.com>,
Dan Murphy <dmurphy@...com>,
Krzysztof Kozlowski <krzk@...nel.org>,
linux-leds@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: Andy Shevchenko <andy.shevchenko@...il.com>
Subject: [PATCH v1 04/28] leds: el15203000: Make error handling more robust
It's easy to miss necessary clean up, e.g. firmware node reference counting,
during error path in ->probe(). Make it more robust by moving to a single
point of return.
Signed-off-by: Andy Shevchenko <andy.shevchenko@...il.com>
---
drivers/leds/leds-el15203000.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/leds/leds-el15203000.c b/drivers/leds/leds-el15203000.c
index 912451db05e6..bcdbbbc9c187 100644
--- a/drivers/leds/leds-el15203000.c
+++ b/drivers/leds/leds-el15203000.c
@@ -246,16 +246,13 @@ static int el15203000_probe_dt(struct el15203000 *priv)
ret = fwnode_property_read_u32(child, "reg", &led->reg);
if (ret) {
dev_err(priv->dev, "LED without ID number");
- fwnode_handle_put(child);
-
- break;
+ goto err_child_out;
}
if (led->reg > U8_MAX) {
dev_err(priv->dev, "LED value %d is invalid", led->reg);
- fwnode_handle_put(child);
-
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_child_out;
}
led->priv = priv;
@@ -277,14 +274,16 @@ static int el15203000_probe_dt(struct el15203000 *priv)
dev_err(priv->dev,
"failed to register LED device %s, err %d",
led->ldev.name, ret);
- fwnode_handle_put(child);
-
- break;
+ goto err_child_out;
}
led++;
}
+ return 0;
+
+err_child_out:
+ fwnode_handle_put(child);
return ret;
}
--
2.31.1
Powered by blists - more mailing lists