* [PATCH] dma-buf/test: add KUnit case for dma_fence_dedup_array() empty input
@ 2026-06-30 6:04 Baineng Shou
2026-06-30 8:29 ` Christian König
0 siblings, 1 reply; 2+ messages in thread
From: Baineng Shou @ 2026-06-30 6:04 UTC (permalink / raw)
To: sumit.semwal, christian.koenig
Cc: linux-media, dri-devel, linaro-mm-sig, linux-kernel, phasta,
tursulin, akash.goel, Baineng Shou
Add a KUnit case verifying that dma_fence_dedup_array() returns 0,
not 1, when called with num_fences == 0. This locks down the
contract documented in the kernel-doc and prevents a regression
of commit 77a9298741f8 ("dma-fence: Make dma_fence_dedup_array()
robust against 0-count input").
Suggested-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Baineng Shou <shoubaineng@gmail.com>
---
drivers/dma-buf/st-dma-fence-unwrap.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/dma-buf/st-dma-fence-unwrap.c b/drivers/dma-buf/st-dma-fence-unwrap.c
index 4e7ee25372ba..72dea6091d58 100644
--- a/drivers/dma-buf/st-dma-fence-unwrap.c
+++ b/drivers/dma-buf/st-dma-fence-unwrap.c
@@ -370,6 +370,15 @@ static void test_unwrap_merge_seqno(struct kunit *test)
dma_fence_put(f1);
}
+static void test_dedup_empty(struct kunit *test)
+{
+ struct dma_fence *fence[1] = { NULL };
+ int ret;
+
+ ret = dma_fence_dedup_array(fence, 0);
+ KUNIT_EXPECT_EQ(test, ret, 0);
+}
+
static void test_unwrap_merge_order(struct kunit *test)
{
struct dma_fence *fence, *f1, *f2, *a1, *a2, *c1, *c2;
@@ -595,6 +604,7 @@ static struct kunit_case dma_fence_unwrap_cases[] = {
KUNIT_CASE(test_unwrap_merge_order),
KUNIT_CASE(test_unwrap_merge_complex),
KUNIT_CASE(test_unwrap_merge_complex_seqno),
+ KUNIT_CASE(test_dedup_empty),
{}
};
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dma-buf/test: add KUnit case for dma_fence_dedup_array() empty input
2026-06-30 6:04 [PATCH] dma-buf/test: add KUnit case for dma_fence_dedup_array() empty input Baineng Shou
@ 2026-06-30 8:29 ` Christian König
0 siblings, 0 replies; 2+ messages in thread
From: Christian König @ 2026-06-30 8:29 UTC (permalink / raw)
To: Baineng Shou, sumit.semwal
Cc: linux-media, dri-devel, linaro-mm-sig, linux-kernel, phasta,
tursulin, akash.goel
On 6/30/26 08:04, Baineng Shou wrote:
> Add a KUnit case verifying that dma_fence_dedup_array() returns 0,
> not 1, when called with num_fences == 0. This locks down the
> contract documented in the kernel-doc and prevents a regression
> of commit 77a9298741f8 ("dma-fence: Make dma_fence_dedup_array()
> robust against 0-count input").
>
> Suggested-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Baineng Shou <shoubaineng@gmail.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Going to push this to drm-misc-next later today. I also pinged our intern to write a cleanup patch whic consistently use size_t for the number of array elements in the code.
Thanks,
Christian.
> ---
> drivers/dma-buf/st-dma-fence-unwrap.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/dma-buf/st-dma-fence-unwrap.c b/drivers/dma-buf/st-dma-fence-unwrap.c
> index 4e7ee25372ba..72dea6091d58 100644
> --- a/drivers/dma-buf/st-dma-fence-unwrap.c
> +++ b/drivers/dma-buf/st-dma-fence-unwrap.c
> @@ -370,6 +370,15 @@ static void test_unwrap_merge_seqno(struct kunit *test)
> dma_fence_put(f1);
> }
>
> +static void test_dedup_empty(struct kunit *test)
> +{
> + struct dma_fence *fence[1] = { NULL };
> + int ret;
> +
> + ret = dma_fence_dedup_array(fence, 0);
> + KUNIT_EXPECT_EQ(test, ret, 0);
> +}
> +
> static void test_unwrap_merge_order(struct kunit *test)
> {
> struct dma_fence *fence, *f1, *f2, *a1, *a2, *c1, *c2;
> @@ -595,6 +604,7 @@ static struct kunit_case dma_fence_unwrap_cases[] = {
> KUNIT_CASE(test_unwrap_merge_order),
> KUNIT_CASE(test_unwrap_merge_complex),
> KUNIT_CASE(test_unwrap_merge_complex_seqno),
> + KUNIT_CASE(test_dedup_empty),
> {}
> };
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-30 8:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30 6:04 [PATCH] dma-buf/test: add KUnit case for dma_fence_dedup_array() empty input Baineng Shou
2026-06-30 8:29 ` 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