From: jsg Date: Fri, 28 Jul 2023 06:35:45 +0000 (+0000) Subject: drm/client: Fix memory leak in drm_client_target_cloned X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=12e89b147f65397cdd32575fe5593c644c5dab26;p=openbsd drm/client: Fix memory leak in drm_client_target_cloned From Jocelyn Falempe b5359d7a5087ac398fc429da6833133b4784c268 in linux-6.1.y/6.1.42 c2a88e8bdf5f6239948d75283d0ae7e0c7945b03 in mainline linux --- diff --git a/sys/dev/pci/drm/drm_client_modeset.c b/sys/dev/pci/drm/drm_client_modeset.c index cb1efe49146..cd658752a40 100644 --- a/sys/dev/pci/drm/drm_client_modeset.c +++ b/sys/dev/pci/drm/drm_client_modeset.c @@ -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; }