From 011d7bfac36dddeea4f9dea6830187d6ee5cdbb6 Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Wed, 22 Oct 2025 08:12:35 +0300 Subject: [PATCH] modesetting: handle some allocation failures Signed-off-by: stefan11111 --- .../drivers/video/modesetting/drmmode_display.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/drivers/video/modesetting/drmmode_display.c b/hw/xfree86/drivers/video/modesetting/drmmode_display.c index 697173d5e4..6f308088a0 100644 --- a/hw/xfree86/drivers/video/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/video/modesetting/drmmode_display.c @@ -2506,8 +2506,12 @@ populate_cursor_sizes(drmmode_ptr drmmode, drmmode_crtc_private_ptr drmmode_crtc if (!size_hints_len) goto fail; + void *tmp = realloc(drmmode_crtc->cursor.dimensions, size_hints_len * sizeof(drmmode_cursor_dim_rec)); + if (!tmp) + goto fail; + + drmmode_crtc->cursor.dimensions = tmp; drmmode_crtc->cursor.num_dimensions = size_hints_len; - drmmode_crtc->cursor.dimensions = xnfrealloc(drmmode_crtc->cursor.dimensions, size_hints_len * sizeof(drmmode_cursor_dim_rec)); for (int idx = 0; idx < size_hints_len; idx++) { @@ -2911,8 +2915,11 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res drmmode_crtc->next_msc = UINT64_MAX; /* Setup the fallback cursor immediately. */ + drmmode_crtc->cursor.dimensions = malloc(sizeof(drmmode_cursor_dim_rec)); + if (drmmode_crtc->cursor.dimensions == NULL) + return 0; + drmmode_crtc->cursor.num_dimensions = 1; - drmmode_crtc->cursor.dimensions = xnfalloc(sizeof(drmmode_cursor_dim_rec)); drmmode_crtc->cursor.dimensions[0] = drmmode_cursor_get_fallback(drmmode_crtc);