prev_sink is unconditionally retained via dc_sink_retain at function
  entry, but the DP alt mode timeout path inside SIGNAL_TYPE_DISPLAY_PORT
  returns false without releasing prev_sink. All other return paths in the
  function correctly call dc_sink_release(prev_sink), making this the only
  missing cleanup.

Cc: [email protected]
Fixes: 54618888d1ea ("drm/amd/display: break down dc_link.c")
Signed-off-by: WenTao Liang <[email protected]>
---
 drivers/gpu/drm/amd/display/dc/link/link_detection.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/link/link_detection.c 
b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
index 794dd6a95918..03bb210ebab8 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
@@ -1069,8 +1069,11 @@ static bool detect_link_and_local_sink(struct dc_link 
*link,
                            link->link_enc->features.flags.bits.DP_IS_USB_C == 
1) {
 
                                /* if alt mode times out, return false */
-                               if (!wait_for_entering_dp_alt_mode(link))
+                               if (!wait_for_entering_dp_alt_mode(link)) {
+                                       if (prev_sink)
+                                               dc_sink_release(prev_sink);
                                        return false;
+                               }
                        }
 
                        if (!detect_dp(link, &sink_caps, reason)) {
-- 
2.39.5 (Apple Git-154)

Reply via email to