From: Alex Hung <[email protected]>

[WHY]
The MST add-connector fixture registers an unmanaged master connector
but does not clean it up before its KUnit-owned storage is released.

[HOW]
Register a KUnit action after successful connector initialization to
run drm_connector_cleanup before freeing the master connector.

Assisted-by: Copilot:GPT-6-Astra
Reviewed-by: Bhawanpreet Lakha <[email protected]>
Signed-off-by: Alex Hung <[email protected]>
Signed-off-by: George Zhang <[email protected]>
---
 .../display/amdgpu_dm/tests/amdgpu_dm_mst_types_test.c   | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git 
a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_mst_types_test.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_mst_types_test.c
index 382eafab2d43..eafa3e6733a6 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_mst_types_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_mst_types_test.c
@@ -1311,6 +1311,13 @@ struct dm_mst_test_add_ctx {
        struct dc_link *link;
 };
 
+static void dm_mst_test_cleanup_add_ctx(void *data)
+{
+       struct amdgpu_dm_connector *master = data;
+
+       drm_connector_cleanup(&master->base);
+}
+
 /*
  * Stand in for amdgpu_display_modeset_create_props(), which the test module
  * cannot link against. Only the properties amdgpu_dm_connector_init_helper()
@@ -1368,6 +1375,8 @@ static void dm_mst_test_init_add_ctx(struct kunit *test, 
struct dm_mst_test_add_
        ret = drm_connector_init(drm, &ctx->master->base, 
&dm_mst_test_connector_funcs,
                                 DRM_MODE_CONNECTOR_DisplayPort);
        KUNIT_ASSERT_EQ(test, ret, 0);
+       KUNIT_ASSERT_EQ(test,
+                       kunit_add_action_or_reset(test, 
dm_mst_test_cleanup_add_ctx, ctx->master), 0);
 
        ctx->port = kunit_kzalloc(test, sizeof(*ctx->port), GFP_KERNEL);
        KUNIT_ASSERT_NOT_NULL(test, ctx->port);
-- 
2.55.0

Reply via email to