drm_analog_tv_mode() and its variants return a drm_display_mode that
needs to be destroyed later one. The
drm_test_connector_helper_tv_get_modes_check() test never does however,
which leads to a memory leak.

Let's make sure it's freed.

Closes: 
https://lore.kernel.org/dri-devel/a7655158a6367ac46194d57f4b7433ef0772a73e.ca...@mailbox.org/
Fixes: 1e4a91db109f ("drm/probe-helper: Provide a TV get_modes helper")
Signed-off-by: Maxime Ripard <mrip...@kernel.org>
---
 drivers/gpu/drm/tests/drm_probe_helper_test.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tests/drm_probe_helper_test.c 
b/drivers/gpu/drm/tests/drm_probe_helper_test.c
index 
bc09ff38aca18eb06dc476310e1dbf372bc5545c..db0e4f5df275e8473ec916ed7a7cf16db96b81c5
 100644
--- a/drivers/gpu/drm/tests/drm_probe_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_probe_helper_test.c
@@ -96,11 +96,11 @@ drm_test_connector_helper_tv_get_modes_check(struct kunit 
*test)
        const struct drm_connector_helper_tv_get_modes_test *params = 
test->param_value;
        struct drm_probe_helper_test_priv *priv = test->priv;
        struct drm_connector *connector = &priv->connector;
        struct drm_cmdline_mode *cmdline = &connector->cmdline_mode;
        struct drm_display_mode *mode;
-       const struct drm_display_mode *expected;
+       struct drm_display_mode *expected;
        size_t len;
        int ret;
 
        if (params->cmdline) {
                cmdline->tv_mode_specified = true;
@@ -132,10 +132,13 @@ drm_test_connector_helper_tv_get_modes_check(struct kunit 
*test)
                expected = params->expected_modes[0](priv->drm);
                KUNIT_ASSERT_NOT_NULL(test, expected);
 
                KUNIT_EXPECT_TRUE(test, drm_mode_equal(mode, expected));
                KUNIT_EXPECT_TRUE(test, mode->type & DRM_MODE_TYPE_PREFERRED);
+
+               ret = drm_kunit_add_mode_destroy_action(test, expected);
+               KUNIT_ASSERT_EQ(test, ret, 0);
        }
 
        if (params->num_expected_modes >= 2) {
                mode = list_next_entry(mode, head);
                KUNIT_ASSERT_NOT_NULL(test, mode);
@@ -143,10 +146,13 @@ drm_test_connector_helper_tv_get_modes_check(struct kunit 
*test)
                expected = params->expected_modes[1](priv->drm);
                KUNIT_ASSERT_NOT_NULL(test, expected);
 
                KUNIT_EXPECT_TRUE(test, drm_mode_equal(mode, expected));
                KUNIT_EXPECT_FALSE(test, mode->type & DRM_MODE_TYPE_PREFERRED);
+
+               ret = drm_kunit_add_mode_destroy_action(test, expected);
+               KUNIT_ASSERT_EQ(test, ret, 0);
        }
 
        mutex_unlock(&priv->drm->mode_config.mutex);
 }
 

-- 
2.49.0

Reply via email to