]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: phy: Fix missing of_node_put() for leds
authorJinjie Ruan <ruanjinjie@huawei.com>
Fri, 30 Aug 2024 02:20:25 +0000 (10:20 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Sep 2024 09:11:34 +0000 (11:11 +0200)
[ Upstream commit 2560db6ede1aaf162a73b2df43e0b6c5ed8819f7 ]

The call of of_get_child_by_name() will cause refcount incremented
for leds, if it succeeds, it should call of_node_put() to decrease
it, fix it.

Fixes: 01e5b728e9e4 ("net: phy: Add a binding for PHY LEDs")
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20240830022025.610844-1-ruanjinjie@huawei.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/phy/phy_device.c

index c895cd178e6a1aa0354e65547c44fb4bd54bcce5..2e4bff6055e2230f9126d7be5c3bad8de214fb3c 100644 (file)
@@ -3164,11 +3164,13 @@ static int of_phy_leds(struct phy_device *phydev)
                err = of_phy_led(phydev, led);
                if (err) {
                        of_node_put(led);
+                       of_node_put(leds);
                        phy_leds_unregister(phydev);
                        return err;
                }
        }
 
+       of_node_put(leds);
        return 0;
 }