]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
phy: ti: da8xx-usb: Handle devm_pm_runtime_enable() errors
authorHaotian Zhang <vulab@iscas.ac.cn>
Mon, 24 Nov 2025 10:57:34 +0000 (18:57 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Jan 2026 10:18:41 +0000 (11:18 +0100)
[ Upstream commit 08aa19de72110df8ac10c9e67349dd884eeed41d ]

devm_pm_runtime_enable() can fail due to memory allocation. The current
code ignores its return value after calling pm_runtime_set_active(),
leaving the device in an inconsistent state if runtime PM initialization
fails.

Check the return value of devm_pm_runtime_enable() and return on
failure. Also move the declaration of 'ret' to the function scope
to support this check.

Fixes: ee8e41b5044f ("phy: ti: phy-da8xx-usb: Add runtime PM support")
Suggested-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patch.msgid.link/20251124105734.1027-1-vulab@iscas.ac.cn
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/phy/ti/phy-da8xx-usb.c

index 68aa595b6ad8d6c302bd1658a8fa72ac00f61a52..256f5238153a520cda86e57ab7f146d55fb670ba 100644 (file)
@@ -180,6 +180,7 @@ static int da8xx_usb_phy_probe(struct platform_device *pdev)
        struct da8xx_usb_phy_platform_data *pdata = dev->platform_data;
        struct device_node      *node = dev->of_node;
        struct da8xx_usb_phy    *d_phy;
+       int ret;
 
        d_phy = devm_kzalloc(dev, sizeof(*d_phy), GFP_KERNEL);
        if (!d_phy)
@@ -233,8 +234,6 @@ static int da8xx_usb_phy_probe(struct platform_device *pdev)
                        return PTR_ERR(d_phy->phy_provider);
                }
        } else {
-               int ret;
-
                ret = phy_create_lookup(d_phy->usb11_phy, "usb-phy",
                                        "ohci-da8xx");
                if (ret)
@@ -249,7 +248,9 @@ static int da8xx_usb_phy_probe(struct platform_device *pdev)
                          PHY_INIT_BITS, PHY_INIT_BITS);
 
        pm_runtime_set_active(dev);
-       devm_pm_runtime_enable(dev);
+       ret = devm_pm_runtime_enable(dev);
+       if (ret)
+               return ret;
        /*
         * Prevent runtime pm from being ON by default. Users can enable
         * it using power/control in sysfs.