From cc8755b73897101c361c13a5140c3ba5c85b3cfa Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Sun, 30 Aug 2026 01:03:57 -0600 Subject: [PATCH] drm/amd/display: Test oversized AUX transfer [WHAT] Add a KUnit test for dm_dp_aux_transfer() covering the message size rejection path. [HOW] Build a drm_dp_aux_msg whose size exceeds the aux_payload buffer and verify that dm_dp_aux_transfer() returns -E2BIG without issuing a transfer. Assisted-by: Copilot:Claude-Opus-5 Reviewed-by: Bhawanpreet Lakha Signed-off-by: Alex Hung Signed-off-by: Chenyu Chen Tested-by: Daniel Wheeler Signed-off-by: Alex Deucher --- .../tests/amdgpu_dm_mst_types_test.c | 21 +++++++++++++++++++ 1 file changed, 21 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 36d3f0eebb50..af2dd5b8e79d 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 @@ -885,6 +885,26 @@ static void dm_mst_test_aux_transfer_non_ack_reply(struct kunit *test) KUNIT_EXPECT_EQ(test, dm_mst_test_last_payload.address, 4U); } +/** + * dm_mst_test_aux_transfer_oversized - oversized AUX message is rejected. + * @test: KUnit test context. + * + * The payload is copied into a 16-byte stack buffer, so a larger message must + * be rejected with -E2BIG before the AUX handle is touched. The guard warns, + * which is the expected behaviour for this caller bug. + */ +static void dm_mst_test_aux_transfer_oversized(struct kunit *test) +{ + struct drm_dp_aux_msg msg = { 0 }; + u8 buffer[17] = { 0 }; + + msg.request = DP_AUX_NATIVE_WRITE; + msg.buffer = buffer; + msg.size = sizeof(buffer); + + KUNIT_EXPECT_EQ(test, dm_dp_aux_transfer(NULL, &msg), (ssize_t)-E2BIG); +} + /** * dm_mst_test_fill_payload_flags_native_write - native write request decode. * @test: KUnit test context. @@ -2089,6 +2109,7 @@ static struct kunit_case dm_mst_types_test_cases[] = { KUNIT_CASE(dm_mst_test_aux_transfer_error_result), KUNIT_CASE(dm_mst_test_aux_transfer_hpd_discon_quirk), KUNIT_CASE(dm_mst_test_aux_transfer_non_ack_reply), + KUNIT_CASE(dm_mst_test_aux_transfer_oversized), /* dm_dp_aux_fill_payload_flags tests */ KUNIT_CASE(dm_mst_test_fill_payload_flags_native_write), KUNIT_CASE(dm_mst_test_fill_payload_flags_native_read),