From: sashiko-bot@kernel.org
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 09/10] drm/ttm/tests: Use dma_resv_alloc in test files
Date: Thu, 27 Aug 2026 13:12:48 +0000 [thread overview]
Message-ID: <20260827131249.3CE9D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260827124910.2245-10-christian.koenig@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Permanent memory leak of dynamically allocated `dma_resv` objects in test files due to unmanaged allocations without proper cleanup on success and error paths.
--
commit 12a4cfd4069727fd22b42f06cb1cc43d2134b9c2
Author: Christian König <ckoenig.leichtzumerken@gmail.com>
drm/ttm/tests: Use dma_resv_alloc in test files
This commit replaces dma_resv_init usage with dma_resv_alloc() in the TTM
test files, moving away from embedded structures to reference-counted
dynamic allocations.
> --- a/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
> +++ b/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
> @@ -339,14 +339,12 @@ static void ttm_bo_unreserve_bulk(struct kunit *test)
[ ... ]
> err = ttm_device_kunit_init(priv, ttm_dev, 0);
> KUNIT_ASSERT_EQ(test, err, 0);
> priv->ttm_dev = ttm_dev;
>
> - dma_resv_init(resv);
> + resv = dma_resv_alloc();
> + KUNIT_ASSERT_NOT_NULL(test, resv);
>
> bo1 = ttm_bo_kunit_init(test, test->priv, BO_SIZE, resv);
> bo2 = ttm_bo_kunit_init(test, test->priv, BO_SIZE, resv);
[Severity: Medium]
Does this leak the dynamically allocated dma_resv object?
Because resv is no longer KUnit-managed, and both bo1 and bo2 take references
to it via ttm_bo_kunit_init(), it seems the object will never be fully freed.
While this function has a dma_resv_put(resv) at the end, bo1 and bo2 are
never explicitly destroyed (e.g., via ttm_bo_fini() as seen in other tests),
leaving the refcount elevated on the success path.
> @@ -441,11 +439,9 @@ static void ttm_bo_fini_shared_resv(struct kunit *test)
> KUNIT_ASSERT_EQ(test, err, 0);
> priv->ttm_dev = ttm_dev;
>
> - external_resv = kunit_kzalloc(test, sizeof(*ttm_dev), GFP_KERNEL);
> + external_resv = dma_resv_alloc();
> KUNIT_ASSERT_NOT_NULL(test, external_resv);
>
> - dma_resv_init(external_resv);
> -
> fence = kunit_kzalloc(test, sizeof(*fence), GFP_KERNEL);
> KUNIT_ASSERT_NOT_NULL(test, fence);
[Severity: Medium]
Can this leak external_resv on the error path?
If the kunit_kzalloc() for the fence fails, the KUNIT_ASSERT_NOT_NULL() macro
will abort the test thread immediately. This bypasses the explicit
dma_resv_put(external_resv) cleanup at the end of the function, leaking the
unmanaged allocation.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260827124910.2245-1-christian.koenig@amd.com?part=9
next prev parent reply other threads:[~2026-08-27 13:12 UTC|newest]
Thread overview: 29+ 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-31 7:37 ` Christian König
2026-08-31 21:09 ` Matthew Brost
2026-08-31 7:31 ` Christian König
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
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-31 20:59 ` Youssef Samir
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 [this message]
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=20260827131249.3CE9D1F000E9@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.