drm/client: Fix memory leak in drm_client_target_cloned
authorjsg <jsg@openbsd.org>
Fri, 28 Jul 2023 06:35:45 +0000 (06:35 +0000)
committerjsg <jsg@openbsd.org>
Fri, 28 Jul 2023 06:35:45 +0000 (06:35 +0000)
From Jocelyn Falempe
b5359d7a5087ac398fc429da6833133b4784c268 in linux-6.1.y/6.1.42
c2a88e8bdf5f6239948d75283d0ae7e0c7945b03 in mainline linux

sys/dev/pci/drm/drm_client_modeset.c

index cb1efe4..cd65875 100644 (file)
@@ -315,6 +315,9 @@ static bool drm_client_target_cloned(struct drm_device *dev,
        can_clone = true;
        dmt_mode = drm_mode_find_dmt(dev, 1024, 768, 60, false);
 
+       if (!dmt_mode)
+               goto fail;
+
        for (i = 0; i < connector_count; i++) {
                if (!enabled[i])
                        continue;
@@ -330,11 +333,13 @@ static bool drm_client_target_cloned(struct drm_device *dev,
                if (!modes[i])
                        can_clone = false;
        }
+       kfree(dmt_mode);
 
        if (can_clone) {
                DRM_DEBUG_KMS("can clone using 1024x768\n");
                return true;
        }
+fail:
        DRM_INFO("kms: can't enable cloning when we probably wanted to.\n");
        return false;
 }