Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andy Shevchenko and committed by
Pavel Machek
d299ae94 3a923639

+3 -4
+3 -4
drivers/leds/leds-lm3697.c
··· 226 226 ret = fwnode_property_read_u32(child, "reg", &control_bank); 227 227 if (ret) { 228 228 dev_err(dev, "reg property missing\n"); 229 - fwnode_handle_put(child); 230 229 goto child_out; 231 230 } 232 231 233 232 if (control_bank > LM3697_CONTROL_B) { 234 233 dev_err(dev, "reg property is invalid\n"); 235 234 ret = -EINVAL; 236 - fwnode_handle_put(child); 237 235 goto child_out; 238 236 } 239 237 ··· 262 264 led->num_leds); 263 265 if (ret) { 264 266 dev_err(dev, "led-sources property missing\n"); 265 - fwnode_handle_put(child); 266 267 goto child_out; 267 268 } 268 269 ··· 286 289 &init_data); 287 290 if (ret) { 288 291 dev_err(dev, "led register err: %d\n", ret); 289 - fwnode_handle_put(child); 290 292 goto child_out; 291 293 } 292 294 293 295 i++; 294 296 } 295 297 298 + return ret; 299 + 296 300 child_out: 301 + fwnode_handle_put(child); 297 302 return ret; 298 303 } 299 304