When running the KUnit tests with memory debugging enabled, a bunch of use-after-free errors are hit. Fix them by using the appropriate alloc manager (which might be none - write back connectors and DP MST ports both have their own lifetime management).
Signed-off-by: John Harrison <[email protected]> CC: Alex Hung <[email protected]> CC: Harry Wentland <[email protected]> --- .../drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c | 2 +- .../drm/amd/display/amdgpu_dm/tests/amdgpu_dm_mst_types_test.c | 2 +- drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_wb_test.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c index 5fdf8ce023b9..aa72934e1fea 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c @@ -9702,7 +9702,7 @@ dm_test_conn_init_ctx_alloc(struct kunit *test, enum signal_type signal) ctx->adev->mode_info.num_crtc = 1; dm_test_create_mode_props(test, ctx->adev); - pdev = kunit_kzalloc(test, sizeof(*pdev), GFP_KERNEL); + pdev = drmm_kzalloc(ctx->drm, sizeof(*pdev), GFP_KERNEL); KUNIT_ASSERT_NOT_NULL(test, pdev); device_initialize(&pdev->dev); pdev->dev.parent = dev; 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 eafa3e6733a6..5dc6cd880169 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 @@ -3833,7 +3833,7 @@ dm_mst_test_alloc_dsc_link_ctx(struct kunit *test, int total_avail_slots) link_srv = kunit_kzalloc(test, sizeof(*link_srv), GFP_KERNEL); res_pool = kunit_kzalloc(test, sizeof(*res_pool), GFP_KERNEL); sink = kunit_kzalloc(test, sizeof(*sink), GFP_KERNEL); - port = kunit_kzalloc(test, sizeof(*port), GFP_KERNEL); + port = kzalloc(sizeof(*port), GFP_KERNEL); KUNIT_ASSERT_NOT_NULL(test, link_srv); KUNIT_ASSERT_NOT_NULL(test, res_pool); KUNIT_ASSERT_NOT_NULL(test, sink); diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_wb_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_wb_test.c index 4bc033fdfa97..f3b64a66cf28 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_wb_test.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_wb_test.c @@ -500,7 +500,7 @@ static void dm_test_wb_connector_init_success(struct kunit *test) dc->links[0] = link; dm->dc = dc; - wbcon = kunit_kzalloc(test, sizeof(*wbcon), GFP_KERNEL); + wbcon = kzalloc_obj(*wbcon); KUNIT_ASSERT_NOT_NULL(test, wbcon); ret = amdgpu_dm_wb_connector_init(dm, wbcon, 0); -- 2.43.0
