]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
power: supply: rt5033_charger: Fix device node reference leaks
authorHaotian Zhang <vulab@iscas.ac.cn>
Mon, 29 Sep 2025 11:32:34 +0000 (19:32 +0800)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Mon, 3 Nov 2025 00:01:56 +0000 (01:01 +0100)
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>
drivers/power/supply/rt5033_charger.c

index 2fdc5843970754270754623ddf8abf758c69e2cf..de724f23e453b3b85c227586b3238a20ad5ef4b0 100644 (file)
@@ -701,6 +701,8 @@ static int rt5033_charger_probe(struct platform_device *pdev)
        np_conn = of_parse_phandle(pdev->dev.of_node, "richtek,usb-connector", 0);
        np_edev = of_get_parent(np_conn);
        charger->edev = extcon_find_edev_by_node(np_edev);
+       of_node_put(np_edev);
+       of_node_put(np_conn);
        if (IS_ERR(charger->edev)) {
                dev_warn(charger->dev, "no extcon device found in device-tree\n");
                goto out;