From f05e235a54c0e7eedf7fe251db4dd5a58655ed3d Mon Sep 17 00:00:00 2001 From: Dominik Kaszewski Date: Wed, 23 Sep 2026 12:20:13 -0400 Subject: [PATCH] drm/amd/display: Fix compound literal stackframe limit [Why] Use of compound literals to initialize heap objects may create stack temporaries when compiling in debug mode. For large objects such as dc_memory_pool which is 2 pages large to avoid cacheline sharing, this causes function stackframe to exceed kernel limit. [How] Replace compound literal with field-by-field initialization. Reported-by: Mark Brown Link: https://lore.kernel.org/all/aq0vYhZXtMqA41wZ@sirena.org.uk/ Signed-off-by: Dominik Kaszewski Signed-off-by: Leo Li Reviewed-by: Nicholas Kazlauskas Reviewed-by: Aric Cyr Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dc_memory_pool.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dc_memory_pool.c b/drivers/gpu/drm/amd/display/dc/dc_memory_pool.c index 904f8c4a4783..087f04d31459 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_memory_pool.c +++ b/drivers/gpu/drm/amd/display/dc/dc_memory_pool.c @@ -107,16 +107,14 @@ __must_check struct dc_memory_pool *dc_memory_pool_create(size_t size, struct dc_memory_pool *pool = page_align_up(unaligned_pool); - *pool = (struct dc_memory_pool){ - .size = size, - .capacity = capacity, - .unaligned_pool = unaligned_pool, - .unaligned_memory = kcalloc(lines + 1, PAGE_SIZE, GFP_KERNEL), - .free_list = kcalloc((uint32_t)capacity, sizeof(atomic_t), - GFP_KERNEL), - .free_head = ATOMIC_INIT(0), - }; + // Compound literals create temporary in debug driver, exceeding stack size + pool->size = size; + pool->capacity = capacity; + pool->unaligned_pool = unaligned_pool; + pool->unaligned_memory = kcalloc(lines + 1, PAGE_SIZE, GFP_KERNEL); pool->memory = page_align_up(pool->unaligned_memory); + pool->free_list = kcalloc((uint32_t)capacity, sizeof(atomic_t), GFP_KERNEL); + pool->free_head = (atomic64_t)ATOMIC_INIT(0); if (!pool->unaligned_memory || !pool->free_list) { dc_memory_pool_destroy(pool);