]> git.baikalelectronics.ru Git - kernel.git/commit
drm: fix drm_dp_mst_port refcount leaks in drm_dp_mst_allocate_vcpi
authorXin Xiong <xiongx18@fudan.edu.cn>
Sun, 19 Jul 2020 15:45:45 +0000 (23:45 +0800)
committerLyude Paul <lyude@redhat.com>
Tue, 4 Aug 2020 16:21:11 +0000 (12:21 -0400)
commit28f1438b645ec81005fc8165f62aa087bd4ea506
treeb49ffd18b62b603fda6aeda5b788b2e70afae88a
parent9b305d970c6ff9b80a210741b6c14ff1b4638c0e
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.

Fixes: 353d6e122702 ("drm/dp: Split drm_dp_mst_allocate_vcpi")
Cc: <stable@vger.kernel.org> # v4.12+
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Lyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200719154545.GA41231@xin-virtual-machine
drivers/gpu/drm/drm_dp_mst_topology.c