Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 02/10] dma-buf/tests: Convert st-dma-resv tests to use dma_resv_alloc
Date: Thu, 27 Aug 2026 13:08:55 +0000	[thread overview]
Message-ID: <20260827130855.9437F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260827124910.2245-3-christian.koenig@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Memory leak of manually allocated 'dma_fence' object on test failure path due to KUNIT_ASSERT_NOT_NULL aborting the test.
--

commit 2140307021746c828365fffb6d1a6a49b2fe2aa6
Author: Christian König <ckoenig.leichtzumerken@gmail.com>
dma-buf/tests: Convert st-dma-resv tests to use dma_resv_alloc

This patch updates the test cases in st-dma-resv.c to use the new
dma_resv_alloc API instead of stack-allocated objects. It introduces
pointer allocations and adds reference counting verification by calling
dma_resv_put for cleanup.

> diff --git a/drivers/dma-buf/st-dma-resv.c b/drivers/dma-buf/st-dma-resv.c
> index 2c43d2d2b0169..b843d90417822 100644
> --- a/drivers/dma-buf/st-dma-resv.c
> +++ b/drivers/dma-buf/st-dma-resv.c
[ ... ]
> @@ -75,33 +77,35 @@ static void test_signaling(struct kunit *test)
>  
>  	dma_fence_enable_signaling(f);
>  
> -	dma_resv_init(&resv);
> -	r = dma_resv_lock(&resv, NULL);
> +	resv = dma_resv_alloc();
> +	KUNIT_ASSERT_NOT_NULL(test, resv);

[Severity: Medium]
Does this code leak the allocated dma_fence 'f' if the assertion fails?

In test_signaling(), 'f' is allocated right before this code block. If
dma_resv_alloc() fails due to memory pressure, KUNIT_ASSERT_NOT_NULL() will
abort the test execution immediately. This bypasses the err_free cleanup
label and leaves 'f' stranded without its corresponding dma_fence_put() call.

Since this pattern is repeated in the other tests below, would it be
possible to either reorder the allocations or use KUNIT_EXPECT_NOT_NULL()
to allow for proper cleanup on failure?

> +
> +	r = dma_resv_lock(resv, NULL);
[ ... ]
> @@ -119,23 +123,25 @@ static void test_for_each(struct kunit *test)
>  
>  	dma_fence_enable_signaling(f);
>  
> -	dma_resv_init(&resv);
> -	r = dma_resv_lock(&resv, NULL);
> +	resv = dma_resv_alloc();
> +	KUNIT_ASSERT_NOT_NULL(test, resv);

[Severity: Medium]
Similarly here in test_for_each(), does a failure on this assertion
leak the 'f' object?

> +
> +	r = dma_resv_lock(resv, NULL);
[ ... ]
> @@ -178,25 +184,27 @@ static void test_for_each_unlocked(struct kunit *test)
>  
>  	dma_fence_enable_signaling(f);
>  
> -	dma_resv_init(&resv);
> -	r = dma_resv_lock(&resv, NULL);
> +	resv = dma_resv_alloc();
> +	KUNIT_ASSERT_NOT_NULL(test, resv);

[Severity: Medium]
Does this assertion also leak 'f' in test_for_each_unlocked() if it fails?

> +
> +	r = dma_resv_lock(resv, NULL);
[ ... ]
> @@ -248,24 +256,26 @@ static void test_get_fences(struct kunit *test)
>  
>  	dma_fence_enable_signaling(f);
>  
> -	dma_resv_init(&resv);
> -	r = dma_resv_lock(&resv, NULL);
> +	resv = dma_resv_alloc();
> +	KUNIT_ASSERT_NOT_NULL(test, resv);

[Severity: Medium]
Does this assertion also leak 'f' in test_get_fences() if it fails?

> +
> +	r = dma_resv_lock(resv, NULL);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260827124910.2245-1-christian.koenig@amd.com?part=2

  reply	other threads:[~2026-08-27 13:08 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27 12:38 Refcounting dma_resv v2 Christian König
2026-08-27 12:38 ` [PATCH 01/10] dma-buf: Add reference counting to dma_resv Christian König
2026-08-27 18:39   ` Andi Shyti
2026-08-28 18:21   ` Danilo Krummrich
2026-08-28 19:17     ` Matthew Brost
2026-08-28 19:34       ` Matthew Brost
2026-08-27 12:38 ` [PATCH 02/10] dma-buf/tests: Convert st-dma-resv tests to use dma_resv_alloc Christian König
2026-08-27 13:08   ` sashiko-bot [this message]
2026-08-27 12:38 ` [PATCH 03/10] drm/gem: Add helper for drm_gem_object resv assignment Christian König
2026-08-27 13:22   ` sashiko-bot
2026-08-27 12:38 ` [PATCH 04/10] drm/gem: Convert drm_gem_private_object_init to return error code Christian König
2026-08-27 13:19   ` sashiko-bot
2026-08-27 12:38 ` [PATCH 05/10] drm/gem: Use dynamic allocation for GEM object dma_resv Christian König
2026-08-27 13:13   ` sashiko-bot
2026-08-27 12:38 ` [PATCH 06/10] drm/mode_config: Use dma_resv_alloc for lockdep annotation Christian König
2026-08-27 13:02   ` sashiko-bot
2026-08-27 12:38 ` [PATCH 07/10] drm/xe: " Christian König
2026-08-27 13:04   ` sashiko-bot
2026-08-27 12:38 ` [PATCH 08/10] drm/i915/gt: Use dma_resv_alloc for VM reservation objects Christian König
2026-08-27 13:11   ` sashiko-bot
2026-08-27 12:38 ` [PATCH 09/10] drm/ttm/tests: Use dma_resv_alloc in test files Christian König
2026-08-27 13:12   ` sashiko-bot
2026-08-27 12:38 ` [PATCH 10/10] dma-buf: Inline dma_resv_init and remove allocated flag Christian König
2026-08-27 13:31   ` sashiko-bot
2026-08-27 13:39 ` ✗ Fi.CI.BUILD: failure for series starting with [01/10] dma-buf: Add reference counting to dma_resv Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260827130855.9437F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox