drm/msm/dsi: Fix double put of the PHY device on probe deferral
PATCH 1/1 drm/msm/dsi: Fix double put of the PHY device on probe deferral
Since commit 6977cc89c875 ("drm/msm/dsi: Fix some reference counted resource leaks"), dsi_get_phy() stores the PHY device it looked up in msm_dsi->phy_dev before it checks whether the PHY driver has bound, and dsi_destroy() drops that reference. dsi_init() calls dsi_destroy() when dsi_get_phy() fails.
Commit c04c3148ca12 ("drm/msm/dsi: Fix missing put_device() call in dsi_get_phy") then added a put_device() for the case where the PHY device exists but has no driver data yet. In that case the reference is now dropped twice, once in dsi_get_phy() and again in dsi_destroy(), so each probe deferral for this reason takes one reference too many from the PHY platform device. Enough deferrals underflow its refcount and free it while it is still registered.
fw_devlink normally keeps the DSI host from probing before its PHY has bound. The path is reached with fw_devlink=permissive or off, and after the deferred probe timeout when no driver matches the PHY device, as the device link is relaxed then and every probe retry of the DSI host drops another reference.
Drop the put_device() and leave the reference to dsi_destroy(). This effectively reverts that commit and brings back the single check that it split in two.
The double put was found with the help of an AI coding assistant during a review of the driver.
---
Found by reading the code; I have not hit this on hardware, and there is no reproducer. Build-tested only: drivers/gpu/drm/msm/ with W=1 (arm64 defconfig) on the base commit below, no new warnings.
I used an AI coding assistant for this work. It found the double put while reviewing the driver and drafted this patch and changelog. I have reviewed the change.
--- drivers/gpu/drm/msm/dsi/dsi.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/gpu/drm/msm/dsi/dsi.c +1 -6
@@ -44,12 +44,7 @@ static int dsi_get_phy(struct msm_dsi *msm_dsi)of_node_put (phy_node); -if (!phy_pdev) { -DRM_DEV_ERROR (&pdev->dev,"%s: phy driver is not ready\n" , __func__); -return -EPROBE_DEFER ; - } -if (!msm_dsi->phy) { -put_device (&phy_pdev->dev); +if (!phy_pdev || !msm_dsi->phy) {DRM_DEV_ERROR (&pdev->dev,"%s: phy driver is not ready\n" , __func__);return -EPROBE_DEFER ; }
---
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
change-id: 20261120-upstream2-msm-dsi-phy-ref-bef3dce3dfe6
Best regards,
Signature · 1 line
yzddMr6 <[email protected]>