Skip to contentSkip to conversation

drm/tests: Initialize framebuffer's filp_head in drm_test_framebuffer_free()

PATCH New Sasha Levin 1 participant 1 message Jun 28, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/tests: Initialize framebuffer's filp_head in drm_test_framebuffer_free()

The drm_test_framebuffer_free() test creates a framebuffer on the stack without properly initializing the filp_head list, causing the following warning when drm_framebuffer_free() checks it:

[  144.996969] drm-kunit-mock-device drm_test_framebuffer_free.drm-kunit-mock-device: [drm] drm_WARN_ON(\!list_empty(&fb->filp_head))
[  144.997097] WARNING: CPU: 0 PID: 2546 at drivers/gpu/drm/drm_framebuffer.c:832 drm_framebuffer_free+0x13f/0x1c0

The test intentionally creates a partially initialized framebuffer to test an edge case in drm_framebuffer_free(), but it needs to initialize the filp_head list to avoid triggering the warning on uninitialized list data.

Initialize the filp_head list in the test to match the behavior of drm_framebuffer_init().

Fixes d21942560499 ("drm/tests: Add test for drm_framebuffer_free()")
---
 drivers/gpu/drm/tests/drm_framebuffer_test.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/tests/drm_framebuffer_test.c +1 -0
index 6ea04cc8f3241..81a7f2cfb8ed6 100644
@@ -677,6 +677,7 @@ static void drm_test_framebuffer_free(struct kunit *test)
 	};
 	int id, ret;
 
+	INIT_LIST_HEAD(&fb.filp_head);
 	priv->buffer_freed = false;
 
 	/*
Signature · 1 line
2.39.5