In detect_link_and_local_sink(), prev_sink is retained via dc_sink_retain() to keep it alive while probing for a new sink. When the link type is DisplayPort and the USB-C alt mode transition times out (i.e. wait_for_entering_dp_alt_mode() returns false), the function returns false without releasing the prev_sink reference acquired earlier. All other error paths after the retain properly release the reference.
Fix this by calling dc_sink_release(prev_sink) before returning on the DP alt mode timeout path. 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 | 4 +++- 1 file changed, 3 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..4473d93b783a 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,10 @@ 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)) { + dc_sink_release(prev_sink); return false; + } } if (!detect_dp(link, &sink_caps, reason)) { -- 2.34.1
