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

leds: lm3532: 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
2f39f68c 99be74f6

+2 -5
+2 -5
drivers/leds/leds-lm3532.c
··· 586 586 ret = fwnode_property_read_u32(child, "reg", &control_bank); 587 587 if (ret) { 588 588 dev_err(&priv->client->dev, "reg property missing\n"); 589 - fwnode_handle_put(child); 590 589 goto child_out; 591 590 } 592 591 ··· 600 601 &led->mode); 601 602 if (ret) { 602 603 dev_err(&priv->client->dev, "ti,led-mode property missing\n"); 603 - fwnode_handle_put(child); 604 604 goto child_out; 605 605 } 606 606 ··· 634 636 led->num_leds); 635 637 if (ret) { 636 638 dev_err(&priv->client->dev, "led-sources property missing\n"); 637 - fwnode_handle_put(child); 638 639 goto child_out; 639 640 } 640 641 ··· 644 647 if (ret) { 645 648 dev_err(&priv->client->dev, "led register err: %d\n", 646 649 ret); 647 - fwnode_handle_put(child); 648 650 goto child_out; 649 651 } 650 652 ··· 651 655 if (ret) { 652 656 dev_err(&priv->client->dev, "register init err: %d\n", 653 657 ret); 654 - fwnode_handle_put(child); 655 658 goto child_out; 656 659 } 657 660 658 661 i++; 659 662 } 663 + return 0; 660 664 661 665 child_out: 666 + fwnode_handle_put(child); 662 667 return ret; 663 668 } 664 669