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

power: supply: rt5033_charger: Fix device node reference leaks

The device node pointers `np_conn` and `np_edev`, obtained from
of_parse_phandle() and of_get_parent() respectively, are not released.
This results in a reference count leak.

Add of_node_put() calls after the last use of these device nodes to
properly release their references and fix the leaks.

Fixes: 8242336dc8a8 ("power: supply: rt5033_charger: Add cable detection and USB OTG supply")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Link: https://patch.msgid.link/20250929113234.1726-1-vulab@iscas.ac.cn
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Haotian Zhang and committed by
Sebastian Reichel
6cdc4d48 1cb053ea

+2
+2
drivers/power/supply/rt5033_charger.c
··· 701 701 np_conn = of_parse_phandle(pdev->dev.of_node, "richtek,usb-connector", 0); 702 702 np_edev = of_get_parent(np_conn); 703 703 charger->edev = extcon_find_edev_by_node(np_edev); 704 + of_node_put(np_edev); 705 + of_node_put(np_conn); 704 706 if (IS_ERR(charger->edev)) { 705 707 dev_warn(charger->dev, "no extcon device found in device-tree\n"); 706 708 goto out;