From f894801fa20ccf342656c815a56d266e81ca4aac Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 20 Feb 2025 17:25:15 +0100 Subject: [PATCH] xfree86: modesetting: don't use VLA even through this specific case is correct and safe, it's safer to remove all VLA usages and forbid them completely by compiler flag. Signed-off-by: Enrico Weigelt, metux IT consult Part-of: --- hw/xfree86/drivers/modesetting/drmmode_display.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c index 2072ce0c5..cf4269403 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -1910,8 +1910,9 @@ drmmode_set_gamma_lut(drmmode_crtc_private_ptr drmmode_crtc, drmmode_prop_info_ptr gamma_lut_info = &drmmode_crtc->props[DRMMODE_CRTC_GAMMA_LUT]; const uint32_t crtc_id = drmmode_crtc->mode_crtc->crtc_id; - uint32_t blob_id; - struct drm_color_lut lut[size]; + struct drm_color_lut *lut = calloc(size, sizeof(struct drm_color_lut)); + if (!lut) + return; assert(gamma_lut_info->prop_id != 0); @@ -1922,13 +1923,17 @@ drmmode_set_gamma_lut(drmmode_crtc_private_ptr drmmode_crtc, lut[i].reserved = 0; } - if (drmModeCreatePropertyBlob(drmmode->fd, lut, sizeof(lut), &blob_id)) + uint32_t blob_id; + if (drmModeCreatePropertyBlob(drmmode->fd, lut, sizeof(lut), &blob_id)) { + free(lut); return; + } drmModeObjectSetProperty(drmmode->fd, crtc_id, DRM_MODE_OBJECT_CRTC, gamma_lut_info->prop_id, blob_id); drmModeDestroyPropertyBlob(drmmode->fd, blob_id); + free(lut); } static void