drm/amd/display: Fix a couple of test failures
Subsystems (3)
cover drm/amd/display: Fix a couple of test failures
Running the KUNIT tests with KASAN enabled hits a couple of memory splats. So let's fix them.
John Harrison (2):
drm/amd/display: Fix use-after-free in
dm_test_vblank_control_worker_enable_increments
drm/amd/display: Fix null pointer deref during
dm_test_i2c_xfer_no_ddc_pin
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c | 2 +- .../gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/2 drm/amd/display: Fix use-after-free in dm_test_vblank_control_worker_enable_increments
The test runs a worker thread and verifies that it did something. However, the worker frees up the work item object that the 'did something' check inspects.
The check is actually looking at data inside a different object (AMD CRTC) but using the work item object to get there. So just save a pointer to the desired CRTC object and use that in the test instead.
--- .../gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c +3 -1
@@ -2019,14 +2019,16 @@ static void dm_test_vblank_control_worker_enable_increments(struct kunit *test) {struct vblank_control_work *work;struct amdgpu_display_manager *dm; +struct amdgpu_crtc *acrtc; work =dm_test_vblank_control_worker_setup (test, true,0 ); dm = work->dm; + acrtc = work->acrtc;amdgpu_dm_crtc_vblank_control_worker (&work->work);KUNIT_EXPECT_EQ (test, dm->active_vblank_irq_count,1 ); -KUNIT_EXPECT_TRUE (test, work->acrtc->dm_irq_params.vblank_irq_programmed); +KUNIT_EXPECT_TRUE (test, acrtc->dm_irq_params.vblank_irq_programmed); }/**
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 1/2] drm/amd/display: Fix use-after-free in dm_test_vblank_control_worker_enable_increments
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] drm/amd/display: missing Fixes trailer in commit message --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] drm/amd/display: missing Fixes trailer in commit message --
commit 743bf16e2134d4dfb68bd75ac4f4ba7434f28d77
Author: John Harrison <[email protected]>
Quoted 11 lines
drm/amd/display: Fix use-after-free in
dm_test_vblank_control_worker_enable_incrementsThe test runs a worker thread and verifies that it did something. However, the worker frees up the work item object that the 'did something' check inspects.
The check is actually looking at data inside a different object (AMD CRTC) but using the work item object to get there. So just save a pointer to the desired CRTC object and use that in the test instead.
Signed-off-by John Harrison <[email protected]>
[Severity: Low]
This fixes the use-after-free on work->acrtc introduced in dm_test_vblank_control_worker_enable_increments(). Should the commit message include:
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH 2/2 drm/amd/display: Fix null pointer deref during dm_test_i2c_xfer_no_ddc_pin
In reply to John HarrisonThe above selftest creates a mimimal I2C device which does not have all the optional extras of a real hardware device. However, since the patch below, the I2C code was assuming some of that state was present. So add a check that 'ddc_service->link' is not null before trying to dereference it.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c +1 -1
@@ -3445,7 +3445,7 @@ STATIC_IFN_KUNIT int amdgpu_dm_i2c_xfer(struct i2c_adapter *i2c_adap,if (!i2c->oem) {struct dc_link *link = ddc_service->link; -struct amdgpu_dm_connector *aconnector = link->priv; +struct amdgpu_dm_connector *aconnector = link ? link->priv :NULL ;/* * DDC to a native DisplayPort sink is tunneled over the AUX
Signature · 1 line
2.43.0