Skip to content

Commit 08aa19d

Browse files
ISCAS-Vulabvinodkoul
authored andcommitted
phy: ti: da8xx-usb: Handle devm_pm_runtime_enable() errors
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: ee8e41b ("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>
1 parent cabd25b commit 08aa19d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

drivers/phy/ti/phy-da8xx-usb.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ static int da8xx_usb_phy_probe(struct platform_device *pdev)
180180
struct da8xx_usb_phy_platform_data *pdata = dev->platform_data;
181181
struct device_node *node = dev->of_node;
182182
struct da8xx_usb_phy *d_phy;
183+
int ret;
183184

184185
d_phy = devm_kzalloc(dev, sizeof(*d_phy), GFP_KERNEL);
185186
if (!d_phy)
@@ -233,8 +234,6 @@ static int da8xx_usb_phy_probe(struct platform_device *pdev)
233234
return PTR_ERR(d_phy->phy_provider);
234235
}
235236
} else {
236-
int ret;
237-
238237
ret = phy_create_lookup(d_phy->usb11_phy, "usb-phy",
239238
"ohci-da8xx");
240239
if (ret)
@@ -249,7 +248,9 @@ static int da8xx_usb_phy_probe(struct platform_device *pdev)
249248
PHY_INIT_BITS, PHY_INIT_BITS);
250249

251250
pm_runtime_set_active(dev);
252-
devm_pm_runtime_enable(dev);
251+
ret = devm_pm_runtime_enable(dev);
252+
if (ret)
253+
return ret;
253254
/*
254255
* Prevent runtime pm from being ON by default. Users can enable
255256
* it using power/control in sysfs.

0 commit comments

Comments
 (0)