Skip to content

Commit d299ae9

Browse files
andy-shevpavelmachek
authored andcommitted
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 <[email protected]> Signed-off-by: Pavel Machek <[email protected]>
1 parent 3a92363 commit d299ae9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/leds/leds-lm3697.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,12 @@ static int lm3697_probe_dt(struct lm3697 *priv)
226226
ret = fwnode_property_read_u32(child, "reg", &control_bank);
227227
if (ret) {
228228
dev_err(dev, "reg property missing\n");
229-
fwnode_handle_put(child);
230229
goto child_out;
231230
}
232231

233232
if (control_bank > LM3697_CONTROL_B) {
234233
dev_err(dev, "reg property is invalid\n");
235234
ret = -EINVAL;
236-
fwnode_handle_put(child);
237235
goto child_out;
238236
}
239237

@@ -264,7 +262,6 @@ static int lm3697_probe_dt(struct lm3697 *priv)
264262
led->num_leds);
265263
if (ret) {
266264
dev_err(dev, "led-sources property missing\n");
267-
fwnode_handle_put(child);
268265
goto child_out;
269266
}
270267

@@ -289,14 +286,16 @@ static int lm3697_probe_dt(struct lm3697 *priv)
289286
&init_data);
290287
if (ret) {
291288
dev_err(dev, "led register err: %d\n", ret);
292-
fwnode_handle_put(child);
293289
goto child_out;
294290
}
295291

296292
i++;
297293
}
298294

295+
return ret;
296+
299297
child_out:
298+
fwnode_handle_put(child);
300299
return ret;
301300
}
302301

0 commit comments

Comments
 (0)