From: sashiko-bot@kernel.org
To: "Robert Mader" <robert.mader@collabora.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v1 2/4] drm/vkms: Make LUT test reusable
Date: Fri, 04 Dec 2026 14:02:18 +0000 [thread overview]
Message-ID: <sashiko-outbox-249922@kernel.org> (raw)
In-Reply-To: <20261204135131.195561-3-robert.mader@collabora.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/vkms: u16 sum overflow in vkms_color_test_inv_lut()
--
commit 88ce71701c6dbe07fa8ad17d5f1c90963dd032aa
Author: Robert Mader <robert.mader@collabora.com>
drm/vkms: Make LUT test reusable
This commit factors the inverse LUT test logic out of
vkms_color_srgb_inv_srgb() into a reusable vkms_color_test_inv_lut()
helper and adds an average error tolerance check.
> diff --git a/drivers/gpu/drm/vkms/tests/vkms_color_test.c b/drivers/gpu/drm/vkms/tests/vkms_color_test.c
> index c3c61037cb711..409e7a7d6861f 100644
> --- a/drivers/gpu/drm/vkms/tests/vkms_color_test.c
> +++ b/drivers/gpu/drm/vkms/tests/vkms_color_test.c
> @@ -120,20 +120,35 @@ static void vkms_color_test_linear(struct kunit *test)
> }
> }
>
> -static void vkms_color_srgb_inv_srgb(struct kunit *test)
> +static void vkms_color_test_inv_lut(struct kunit *test,
> + const struct vkms_color_lut *lut,
> + const struct vkms_color_lut *inv_lut,
> + u16 tolerance_max,
> + u16 tolerance_avg)
> {
> - u16 srgb, final;
> - u16 tolerance = 11;
> + u16 sum = 0;
> + u16 count = 0;
> + u16 tmp, final;
> u32 x;
>
> for (u32 i = 0; i <= 4095; i++) {
> x = i * U16_MAX / 4095;
> - srgb = apply_lut_to_channel_value(&srgb_eotf, x, LUT_RED);
> - final = apply_lut_to_channel_value(&srgb_inv_eotf, srgb, LUT_RED);
> + tmp = apply_lut_to_channel_value(lut, x, LUT_RED);
> + final = apply_lut_to_channel_value(inv_lut, tmp, LUT_RED);
> +
> + KUNIT_EXPECT_GE(test, final, (int)x - tolerance_max);
> + KUNIT_EXPECT_LE(test, final, (int)x + tolerance_max);
>
> - KUNIT_EXPECT_GE(test, final, (int)x - tolerance);
> - KUNIT_EXPECT_LE(test, final, (int)x + tolerance);
> + sum += abs((int)x - final);
> + count++;
> }
> +
> + KUNIT_EXPECT_LE(test, sum / count, tolerance_avg);
[Severity: Medium]
Can sum overflow here?
sum is a u16 accumulating errors across 4096 samples, so it wraps modulo
65536 as soon as the average error reaches 16 (and the true total can reach
4096 * U16_MAX). This caps sum / count at 15 and lets a regressed LUT
falsely pass KUNIT_EXPECT_LE(test, sum / count, tolerance_avg).
Using u32 for sum would avoid the overflow.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204135131.195561-1-robert.mader@collabora.com?part=2
next prev parent reply other threads:[~2026-12-04 14:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 13:50 [PATCH v1 0/4] drm/vkms: Add gamma 2.2 and 2.4 1D curve colorops Robert Mader
2026-12-04 13:50 ` [PATCH v1 1/4] drm/vkms: Fix inverse lut naming scheme in script Robert Mader
2026-12-04 13:50 ` [PATCH v1 2/4] drm/vkms: Make LUT test reusable Robert Mader
2026-12-04 14:02 ` sashiko-bot [this message]
2026-12-04 13:50 ` [PATCH v1 3/4] drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA22 Robert Mader
2026-12-04 14:18 ` sashiko-bot
2026-12-04 13:50 ` [PATCH v1 4/4] drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA24 Robert Mader
2026-12-04 14:35 ` sashiko-bot
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=sashiko-outbox-249922@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=robert.mader@collabora.com \
--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