[PATCH] drm/dp_mst: Avoid NULL pointer dereference

Lipski, Mikita Mikita.Lipski at amd.com
Thu Dec 26 15:04:17 UTC 2019

[AMD Official Use Only - Internal Distribution Only]

Thanks for the catch,

Reviewed-by: Mikita Lipski <Mikita.Lipski at amd.com>

From: Wayne Lin <Wayne.Lin at amd.com>

Sent: Wednesday, December 25, 2019 9:31 PM

To: dri-devel at lists.freedesktop.org <dri-devel at lists.freedesktop.org>; amd-gfx at lists.freedesktop.org <amd-gfx at lists.freedesktop.org>

Cc: lyude at redhat.com <lyude at redhat.com>; Kazlauskas, Nicholas <Nicholas.Kazlauskas at amd.com>; Wentland, Harry <Harry.Wentland at amd.com>; Lipski, Mikita <Mikita.Lipski at amd.com>; Zuo, Jerry <Jerry.Zuo at amd.com>; stable at vger.kernel.org <stable at vger.kernel.org>;
 Lin, Wayne <Wayne.Lin at amd.com>

Subject: [PATCH] drm/dp_mst: Avoid NULL pointer dereference


Found kernel NULL pointer dereference under the below situation:

        src — HDMI_Monitor   src — HDMI_Monitor

e.g.:       \            =>

             MSTB — MSTB     (unplug) MSTB — MSTB

When display 1 HDMI and 2 DP daisy chain monitors, unplugging the dp

cable connected to source causes kernel NULL pointer dereference at

drm_dp_mst_atomic_check_bw_limit(). When calculating pbn_limit, if

branch is null, accessing "&branch->ports" causes the problem.


Judge branch is null or not at the beginning. If it is null, return 0.

Signed-off-by: Wayne Lin <Wayne.Lin at amd.com>

Cc: stable at vger.kernel.org


 drivers/gpu/drm/drm_dp_mst_topology.c | 3 +++

 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c

index 7d2d31eaf003..a6473e3ab448 100644

--- a/drivers/gpu/drm/drm_dp_mst_topology.c

+++ b/drivers/gpu/drm/drm_dp_mst_topology.c

@@ -4707,6 +4707,9 @@ int drm_dp_mst_atomic_check_bw_limit(struct drm_dp_mst_branch *branch,

         struct drm_dp_vcpi_allocation *vcpi;

         int pbn_limit = 0, pbn_used = 0;

+       if (!branch)

+               return 0;


         list_for_each_entry(port, &branch->ports, next) {

                 if (port->mstb)

                         if (drm_dp_mst_atomic_check_bw_limit(port->mstb, mst_state))



More information about the amd-gfx mailing list