From: Arina Kharlamova <[email protected]>

detect_reg() jumps to the out label when pm_runtime_resume_and_get()
fails and then calls pm_runtime_put(). The failed call did not take a
usage count, so this drops a reference owned by someone else, or warns
about an underflow.

Only read the status register and drop the reference when the resume
succeeded.

Fixes: 81aa83419706 ("drm/msm/hdmi: switch to pm_runtime_resume_and_get()")
Signed-off-by: Arina Kharlamova <[email protected]>
---
Found by checks derived from the spec2patch kernel API specifications,
with the help of an AI coding assistant (Claude); I reviewed the
analysis and the fix.
---
 drivers/gpu/drm/msm/hdmi/hdmi_hpd.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_hpd.c 
b/drivers/gpu/drm/msm/hdmi/hdmi_hpd.c
index 2cccd9062584..03e33ece890a 100644
--- a/drivers/gpu/drm/msm/hdmi/hdmi_hpd.c
+++ b/drivers/gpu/drm/msm/hdmi/hdmi_hpd.c
@@ -157,13 +157,10 @@ static enum drm_connector_status detect_reg(struct hdmi 
*hdmi)
        int ret;
 
        ret = pm_runtime_resume_and_get(&hdmi->pdev->dev);
-       if (ret)
-               goto out;
-
-       hpd_int_status = hdmi_read(hdmi, REG_HDMI_HPD_INT_STATUS);
-
-out:
-       pm_runtime_put(&hdmi->pdev->dev);
+       if (!ret) {
+               hpd_int_status = hdmi_read(hdmi, REG_HDMI_HPD_INT_STATUS);
+               pm_runtime_put(&hdmi->pdev->dev);
+       }
 
        return (hpd_int_status & HDMI_HPD_INT_STATUS_CABLE_DETECTED) ?
                        connector_status_connected : 
connector_status_disconnected;

---
base-commit: 25faec9ce61c01fb45abf812a222c5b43c3cd5c5
change-id: 20261129-s2p-c04-4bd8da94154d

Best regards,
--  
Arina Kharlamova <[email protected]>


Reply via email to