drm: fix drm_dp_mst_port refcount leaks in drm_dp_mst_allocate_vcpi
Subsystems (2)
PATCH 1/1 drm: fix drm_dp_mst_port refcount leaks in drm_dp_mst_allocate_vcpi
drm_dp_mst_allocate_vcpi() invokes drm_dp_mst_topology_get_port_validated(), which increases the refcount of the "port".
These reference counting issues take place in two exception handling paths separately. Either when “slots” is less than 0 or when drm_dp_init_vcpi() returns a negative value, the function forgets to reduce the refcnt increased drm_dp_mst_topology_get_port_validated(), which results in a refcount leak.
Fix these issues by pulling up the error handling when "slots" is less than 0, and calling drm_dp_mst_topology_put_port() before termination when drm_dp_init_vcpi() returns a negative value.
--- drivers/gpu/drm/drm_dp_mst_topology.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_dp_mst_topology.c +4 -3
@@ -4261,11 +4261,11 @@ bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, {int ret; - port =drm_dp_mst_topology_get_port_validated (mgr, port); -if (!port) +if (slots <0 )return false; -if (slots <0 ) + port =drm_dp_mst_topology_get_port_validated (mgr, port); +if (!port)return false;if (port->vcpi.vcpi >0 ) {
@@ -4281,6 +4281,7 @@ bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr,if (ret) {DRM_DEBUG_KMS ("failed to init vcpi slots=%d max=63 ret=%d\n" ,DIV_ROUND_UP (pbn, mgr->pbn_div), ret); +drm_dp_mst_topology_put_port (port); goto out; } DRM_DEBUG_KMS("initing vcpi for pbn=%d slots=%d\n",
Signature · 1 line
2.25.1
Hi Xin Xong,
I have seen insufficient vcpi ports issues with MST daisy chain. While running the IGT tests on MST, some times the vcpi ports are all used up.
Due to this the atomic check fails and the flips start failing with ENOSPC.
<https://gitlab.freedesktop.org/drm/intel/-/issues/1255>
https://gitlab.freedesktop.org/drm/intel/-/issues/1255
I think this patch would be fixing this.
Regards,
Ankit
Quoted 41 lines · Xin Xiong
drm_dp_mst_allocate_vcpi()invokesdrm_dp_mst_topology_get_port_validated(), which increases the refcount of the "port".These reference counting issues take place in two exception handling paths separately. Either when “slots” is less than 0 or when
drm_dp_init_vcpi()returns a negative value, the function forgets to reduce the refcnt increaseddrm_dp_mst_topology_get_port_validated(), which results in a refcount leak.Fix these issues by pulling up the error handling when "slots" is less than 0, and calling
drm_dp_mst_topology_put_port()before termination whendrm_dp_init_vcpi()returns a negative value.Signed-off-by Xiyu Yang <[email protected]>Signed-off-by Xin Tan <[email protected]>Signed-off-by Xin Xiong <[email protected]>--- drivers/gpu/drm/drm_dp_mst_topology.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_dp_mst_topology.c +3
-3@@ -4261,11 +4261,11 @@ bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, {int ret; - port =drm_dp_mst_topology_get_port_validated (mgr, port); -if (!port) +if (slots <0 )return false; -if (slots <0 ) + port =drm_dp_mst_topology_get_port_validated (mgr, port); +if (!port)return false;if (port->vcpi.vcpi >0 ) {
drivers/gpu/drm/drm_dp_mst_topology.c bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, · line 4287
Quoted 7 lines
drivers/gpu/drm/drm_dp_mst_topology.c +1
-0@@ -4281,6 +4281,7 @@ bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr,if (ret) {DRM_DEBUG_KMS ("failed to init vcpi slots=%d max=63 ret=%d\n" ,DIV_ROUND_UP (pbn, mgr->pbn_div), ret); +drm_dp_mst_topology_put_port (port); goto out; } DRM_DEBUG_KMS("initing vcpi for pbn=%d slots=%d\n",
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heh, I remember this being mentioned to me way back but completely forgot to ever go fix it. Thanks for the patch!
This is missing a Fixes: tag though:
So I will go ahead and add that, then push this to drm-misc-next-fixes. Thanks!
Quoted 50 lines · Xin Xiong
drm_dp_mst_allocate_vcpi()invokesdrm_dp_mst_topology_get_port_validated(), which increases the refcount of the "port".These reference counting issues take place in two exception handling paths separately. Either when “slots” is less than 0 or when
drm_dp_init_vcpi()returns a negative value, the function forgets to reduce the refcnt increaseddrm_dp_mst_topology_get_port_validated(), which results in a refcount leak.Fix these issues by pulling up the error handling when "slots" is less than 0, and calling
drm_dp_mst_topology_put_port()before termination whendrm_dp_init_vcpi()returns a negative value.Signed-off-by Xiyu Yang <[email protected]>Signed-off-by Xin Tan <[email protected]>Signed-off-by Xin Xiong <[email protected]>--- drivers/gpu/drm/drm_dp_mst_topology.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_dp_mst_topology.c +3
-3@@ -4261,11 +4261,11 @@ bool drm_dp_mst_allocate_vcpi(structdrm_dp_mst_topology_mgr *mgr, { int ret; - port =drm_dp_mst_topology_get_port_validated (mgr, port); -if (!port) +if (slots <0 )return false; -if (slots <0 ) + port =drm_dp_mst_topology_get_port_validated (mgr, port); +if (!port)return false;drivers/gpu/drm/drm_dp_mst_topology.c +1
-0if (port->vcpi.vcpi >0 ) {@@ -4281,6 +4281,7 @@ bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, if (ret) {DRM_DEBUG_KMS ("failed to init vcpi slots=%d max=63 ret=%d\n" ,DIV_ROUND_UP (pbn, mgr->pbn_div), ret); +drm_dp_mst_topology_put_port (port); goto out; }
Quoted 1 line
DRM_DEBUG_KMS("initing vcpi for pbn=%d slots=%d\n",
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel