Re: [PATCH] auxdisplay: ht16k33: Drop device node reference after registration failure in ht16k33_led_probe()

From: Andy Shevchenko
Date: Tue Jun 04 2024 - 12:44:14 EST


On Tue, Jun 04, 2024 at 05:15:37PM +0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
> Date: Tue, 4 Jun 2024 17:02:15 +0200
>
> A failed call of the function “devm_led_classdev_register_ext”
> can be reported.
> Add a call of the function “fwnode_handle_put” for this error case.

Replace double quotes by parentheses, so the reference to the functions
will look like func().

...

> err = devm_led_classdev_register_ext(dev, led, &init_data);
> - if (err)
> + if (err) {
> dev_err(dev, "Failed to register LED\n");
> + fwnode_handle_put(init_data.fwnode);
> + }

There are two issues with this approach:
1) there is the same issue in ->remove(), isn't it?
2) it potentially might mess up the ordering if any other devm call happens
in beetween.

But, by design we don't use reference counting after we registered LED, hence
both error and successful paths need to have this, so add another
fwnode_handle_put() after this branch.

--
With Best Regards,
Andy Shevchenko