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