leds: sgm3140: Put the child node reference on success
PATCH 1/1 leds: sgm3140: Put the child node reference on success
sgm3140_probe() gets the LED child node with device_get_next_child_node(), which returns it with its reference count raised. The error path puts the reference, but a successful probe returns before reaching that code, so the reference is never dropped. The v4l2 flash sub-device takes its own reference on the node, and the LED class device only stores the pointer, so nothing else needs the probe's reference after probe returns.
Put the reference before returning success.
--- drivers/leds/flash/leds-sgm3140.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/leds/flash/leds-sgm3140.c +2 -1
@@ -273,7 +273,8 @@ static int sgm3140_probe(struct platform_device *pdev) goto err; } -return ret; +fwnode_handle_put (child_node); +return 0 ; err:fwnode_handle_put (child_node);
Signature · 1 line
2.25.1
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 11 lines
sgm3140_probe()gets the LED child node withdevice_get_next_child_node(), which returns it with its reference count raised. The error path puts the reference, but a successful probe returns before reaching that code, so the reference is never dropped. The v4l2 flash sub-device takes its own reference on the node, and the LED class device only stores the pointer, so nothing else needs the probe's reference after probe returns.Put the reference before returning success.
Fixes cef8ec8cbd21 ("leds: add sgm3140 driver")Signed-off-by Cong Nguyen <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
…
Quoted 1 line
Put the reference before returning success.
Please avoid a bit of duplicate source.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v7.4-rc4#n526
How do you think about to apply the attribute “__free(fwnode_handle_put)” also in the implementation of the function “sgm3140_probe”?
https://elixir.bootlin.com/linux/v7.4-rc1/source/include/linux/property.h#L229
https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/leds/flash/leds-sgm3140.c#L185-L281
Regards,
Markus