drm/dp_mst: Fix NULL deref in get_mst_branch_device_by_guid_helper()
authorjsg <jsg@openbsd.org>
Fri, 3 Nov 2023 03:29:36 +0000 (03:29 +0000)
committerjsg <jsg@openbsd.org>
Fri, 3 Nov 2023 03:29:36 +0000 (03:29 +0000)
From Lukasz Majczak
6c668e2f338bde76279aeaf4d4c035c4196a479b in linux-6.1.y/6.1.61
3d887d512494d678b17c57b835c32f4e48d34f26 in mainline linux

sys/dev/pci/drm/display/drm_dp_mst_topology.c

index a0f8b05..cb6a61a 100644 (file)
@@ -2584,14 +2584,14 @@ static struct drm_dp_mst_branch *get_mst_branch_device_by_guid_helper(
        struct drm_dp_mst_branch *found_mstb;
        struct drm_dp_mst_port *port;
 
+       if (!mstb)
+               return NULL;
+
        if (memcmp(mstb->guid, guid, 16) == 0)
                return mstb;
 
 
        list_for_each_entry(port, &mstb->ports, next) {
-               if (!port->mstb)
-                       continue;
-
                found_mstb = get_mst_branch_device_by_guid_helper(port->mstb, guid);
 
                if (found_mstb)