diff options
author | Andy Shevchenko <andy.shevchenko@gmail.com> | 2021-05-29 14:19:32 +0300 |
---|---|---|
committer | Pavel Machek <pavel@ucw.cz> | 2021-08-03 23:49:31 +0200 |
commit | d299ae942e0201ce3419501f523fbaac989dd036 (patch) | |
tree | d9b6fb9611f5caa7d5f0691e8e3ccb11f5fdde13 /drivers | |
parent | 3a923639d36b1c54866236c2f53d112b797b0101 (diff) | |
download | linux-d299ae942e0201ce3419501f523fbaac989dd036.tar.gz linux-d299ae942e0201ce3419501f523fbaac989dd036.tar.bz2 linux-d299ae942e0201ce3419501f523fbaac989dd036.zip |
leds: lm3697: 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@gmail.com>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/leds/leds-lm3697.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/leds/leds-lm3697.c b/drivers/leds/leds-lm3697.c index 292d64b2eeab..a8c9322558cc 100644 --- a/drivers/leds/leds-lm3697.c +++ b/drivers/leds/leds-lm3697.c @@ -226,14 +226,12 @@ static int lm3697_probe_dt(struct lm3697 *priv) ret = fwnode_property_read_u32(child, "reg", &control_bank); if (ret) { dev_err(dev, "reg property missing\n"); - fwnode_handle_put(child); goto child_out; } if (control_bank > LM3697_CONTROL_B) { dev_err(dev, "reg property is invalid\n"); ret = -EINVAL; - fwnode_handle_put(child); goto child_out; } @@ -264,7 +262,6 @@ static int lm3697_probe_dt(struct lm3697 *priv) led->num_leds); if (ret) { dev_err(dev, "led-sources property missing\n"); - fwnode_handle_put(child); goto child_out; } @@ -289,14 +286,16 @@ static int lm3697_probe_dt(struct lm3697 *priv) &init_data); if (ret) { dev_err(dev, "led register err: %d\n", ret); - fwnode_handle_put(child); goto child_out; } i++; } + return ret; + child_out: + fwnode_handle_put(child); return ret; } |