drm/client: fix null pointer dereference in drm_client_modeset_probe
authorjsg <jsg@openbsd.org>
Thu, 15 Aug 2024 03:20:40 +0000 (03:20 +0000)
committerjsg <jsg@openbsd.org>
Thu, 15 Aug 2024 03:20:40 +0000 (03:20 +0000)
From Ma Ke
d64fc94f7bb24fc2be0d6bd5df8df926da461a6d in linux-6.6.y/6.6.46
113fd6372a5bb3689aba8ef5b8a265ed1529a78f in mainline linux

sys/dev/pci/drm/drm_client_modeset.c

index 21b9c6b..5c5b0a9 100644 (file)
@@ -879,6 +879,11 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width,
 
                        kfree(modeset->mode);
                        modeset->mode = drm_mode_duplicate(dev, mode);
+                       if (!modeset->mode) {
+                               ret = -ENOMEM;
+                               break;
+                       }
+
                        drm_connector_get(connector);
                        modeset->connectors[modeset->num_connectors++] = connector;
                        modeset->x = offset->x;