[PATCH] drm/amdgpu/display: Fix dc_sink refcnt leak when detecting link
Xiyu Yang
xiyuyang19 at fudan.edu.cn
Thu Apr 23 05:05:51 UTC 2020
emulated_link_detect() invokes dc_sink_retain(), which increases the
refcount of the "prev_sink".
When emulated_link_detect() returns, local variable "prev_sink" becomes
invalid, so the refcount should be decreased to keep refcount balanced.
The reference counting issue happens in all paths of
emulated_link_detect(), which forgets to decrease the refcnt increased
by dc_sink_retain(), causing a refcnt leak.
Fix this issue by adding a "err_sink_put" label and calling
dc_sink_release() before emulated_link_detect() returns.
Signed-off-by: Xiyu Yang <xiyuyang19 at fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf at gmail.com>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index e997251a8b57..1b0c4f11b9b1 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -1633,7 +1633,7 @@ static void emulated_link_detect(struct dc_link *link)
default:
DC_ERROR("Invalid connector type! signal:%d\n",
link->connector_signal);
- return;
+ goto err_sink_put;
}
sink_init_data.link = link;
@@ -1642,7 +1642,7 @@ static void emulated_link_detect(struct dc_link *link)
sink = dc_sink_create(&sink_init_data);
if (!sink) {
DC_ERROR("Failed to create sink!\n");
- return;
+ goto err_sink_put;
}
/* dc_sink_create returns a new reference */
@@ -1655,6 +1655,9 @@ static void emulated_link_detect(struct dc_link *link)
if (edid_status != EDID_OK)
DC_ERROR("Failed to read EDID");
+err_sink_put:
+ if (prev_sink != NULL)
+ dc_sink_release(prev_sink);
}
--
2.7.4
More information about the amd-gfx
mailing list