mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/test: drm_exec: fix memory leak on object prepare
@ 2023-07-27 23:10 Danilo Krummrich
  2023-08-08 13:16 ` Christian König
  0 siblings, 1 reply; 2+ messages in thread
From: Danilo Krummrich @ 2023-07-27 23:10 UTC (permalink / raw)
  To: airlied, daniel, christian.koenig, alexander.deucher, arthurgrillo
  Cc: dri-devel, linux-kernel, Danilo Krummrich

drm_exec_prepare_obj() and drm_exec_prepare_array() both reserve
dma-fence slots and hence a dma_resv_list without ever freeing it.

Make sure to call drm_gem_private_object_fini() for each GEM object
passed to drm_exec_prepare_obj()/drm_exec_prepare_array() throughout the
test to fix this up.

While at it, remove some trailing empty lines.

Fixes: 9710631cc8f3 ("drm: add drm_exec selftests v4")
Signed-off-by: Danilo Krummrich <dakr@redhat.com>
---
 drivers/gpu/drm/tests/drm_exec_test.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tests/drm_exec_test.c b/drivers/gpu/drm/tests/drm_exec_test.c
index df31f89a7945..80761e734a15 100644
--- a/drivers/gpu/drm/tests/drm_exec_test.c
+++ b/drivers/gpu/drm/tests/drm_exec_test.c
@@ -118,8 +118,6 @@ static void test_duplicates(struct kunit *test)
 	drm_exec_fini(&exec);
 }
 
-
-
 static void test_prepare(struct kunit *test)
 {
 	struct drm_gem_object gobj = { };
@@ -137,6 +135,8 @@ static void test_prepare(struct kunit *test)
 			break;
 	}
 	drm_exec_fini(&exec);
+
+	drm_gem_private_object_fini(&gobj);
 }
 
 static void test_prepare_array(struct kunit *test)
@@ -156,6 +156,9 @@ static void test_prepare_array(struct kunit *test)
 					     1);
 	KUNIT_EXPECT_EQ(test, ret, 0);
 	drm_exec_fini(&exec);
+
+	drm_gem_private_object_fini(&gobj1);
+	drm_gem_private_object_fini(&gobj2);
 }
 
 static struct kunit_case drm_exec_tests[] = {
-- 
2.41.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/test: drm_exec: fix memory leak on object prepare
  2023-07-27 23:10 [PATCH] drm/test: drm_exec: fix memory leak on object prepare Danilo Krummrich
@ 2023-08-08 13:16 ` Christian König
  0 siblings, 0 replies; 2+ messages in thread
From: Christian König @ 2023-08-08 13:16 UTC (permalink / raw)
  To: Danilo Krummrich, airlied, daniel, alexander.deucher, arthurgrillo
  Cc: dri-devel, linux-kernel

Am 28.07.23 um 01:10 schrieb Danilo Krummrich:
> drm_exec_prepare_obj() and drm_exec_prepare_array() both reserve
> dma-fence slots and hence a dma_resv_list without ever freeing it.
>
> Make sure to call drm_gem_private_object_fini() for each GEM object
> passed to drm_exec_prepare_obj()/drm_exec_prepare_array() throughout the
> test to fix this up.
>
> While at it, remove some trailing empty lines.
>
> Fixes: 9710631cc8f3 ("drm: add drm_exec selftests v4")
> Signed-off-by: Danilo Krummrich <dakr@redhat.com>

Thanks, can you please rebase on current drm-misc-next and re-send.

Thanks,
Christian.

> ---
>   drivers/gpu/drm/tests/drm_exec_test.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/tests/drm_exec_test.c b/drivers/gpu/drm/tests/drm_exec_test.c
> index df31f89a7945..80761e734a15 100644
> --- a/drivers/gpu/drm/tests/drm_exec_test.c
> +++ b/drivers/gpu/drm/tests/drm_exec_test.c
> @@ -118,8 +118,6 @@ static void test_duplicates(struct kunit *test)
>   	drm_exec_fini(&exec);
>   }
>   
> -
> -
>   static void test_prepare(struct kunit *test)
>   {
>   	struct drm_gem_object gobj = { };
> @@ -137,6 +135,8 @@ static void test_prepare(struct kunit *test)
>   			break;
>   	}
>   	drm_exec_fini(&exec);
> +
> +	drm_gem_private_object_fini(&gobj);
>   }
>   
>   static void test_prepare_array(struct kunit *test)
> @@ -156,6 +156,9 @@ static void test_prepare_array(struct kunit *test)
>   					     1);
>   	KUNIT_EXPECT_EQ(test, ret, 0);
>   	drm_exec_fini(&exec);
> +
> +	drm_gem_private_object_fini(&gobj1);
> +	drm_gem_private_object_fini(&gobj2);
>   }
>   
>   static struct kunit_case drm_exec_tests[] = {


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-08 16:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-27 23:10 [PATCH] drm/test: drm_exec: fix memory leak on object prepare Danilo Krummrich
2023-08-08 13:16 ` Christian König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®