From: sashiko-bot@kernel.org
To: "Oarora Etimis" <oaroraetimis@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 4/7] drm/vkms: add a programmable 1D LUT colorop
Date: Sat, 28 Nov 2026 17:25:57 +0000 [thread overview]
Message-ID: <sashiko-outbox-238876@kernel.org> (raw)
In-Reply-To: <20261128-colorop-v1-4-dd79919f822b@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/vkms: raw 64-bit divisions in
apply_lut32_to_channel_value() break 32-bit builds
- [Medium] drm/vkms: NULL dereference on init failure in
vkms_initialize_color_pipeline()
--
commit 780023413d21504e42acdc03ff98ae1aafe4ed37
Author: Oarora Etimis <oaroraetimis@gmail.com>
drm/vkms: add a programmable 1D LUT colorop
This commit adds a 256-entry 1D LUT colorop with linear interpolation to
the VKMS plane color pipeline, implements its lookup in the composer, and
adds KUnit tests for the interpolation.
> diff --git a/drivers/gpu/drm/vkms/vkms_colorop.c b/drivers/gpu/drm/vkms/vkms_colorop.c
> index 01b1ed2a59911..584305b0abfdd 100644
> --- a/drivers/gpu/drm/vkms/vkms_colorop.c
> +++ b/drivers/gpu/drm/vkms/vkms_colorop.c
> @@ -119,6 +119,25 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
>
> drm_colorop_set_next_property(ops[i - 1], ops[i]);
>
> + i++;
> +
> + /* 6th op: 1D LUT */
> + ops[i] = kzalloc_obj(*ops[i]);
> + if (!ops[i]) {
> + drm_err(dev, "KMS: Failed to allocate colorop\n");
> + ret = -ENOMEM;
> + goto cleanup;
> + }
> +
> + ret = drm_plane_colorop_curve_1d_lut_init(dev, ops[i], plane, &vkms_colorop_funcs,
> + VKMS_LUT1D_SIZE,
> + DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR,
> + DRM_COLOROP_FLAG_ALLOW_BYPASS);
> + if (ret)
> + goto cleanup;
[Severity: Medium]
Can this error jump dereference a NULL pointer in drm_colorop_cleanup()?
If drm_plane_colorop_curve_1d_lut_init() -> drm_plane_colorop_init() fails
in drm_mode_object_add(), it returns before setting ops[i]->dev or linking
ops[i]->head:
drivers/gpu/drm/drm_colorop.c:drm_plane_colorop_init() {
...
ret = drm_mode_object_add(dev, &colorop->base, DRM_MODE_OBJECT_COLOROP);
if (ret)
return ret;
colorop->base.properties = &colorop->properties;
colorop->dev = dev;
...
list_add_tail(&colorop->head, &config->colorop_list);
...
}
The cleanup loop in vkms_initialize_color_pipeline() iterates up to j <= i
and calls drm_colorop_cleanup(ops[i]), which runs list_del(&colorop->head)
on zeroed list pointers and dereferences colorop->dev.
> diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
> index 2cd909bc8adcf..e00d1d0b2f2d9 100644
> --- a/drivers/gpu/drm/vkms/vkms_composer.c
> +++ b/drivers/gpu/drm/vkms/vkms_composer.c
[ ... ]
> @@ -198,6 +201,61 @@ VISIBLE_IF_KUNIT u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut
[ ... ]
> +VISIBLE_IF_KUNIT u16 apply_lut32_to_channel_value(const struct drm_color_lut32 *lut,
> + u32 lut_size, u16 channel_value,
> + enum lut_channel channel)
> +{
> + u64 position;
> + u32 index, fraction;
> + s64 delta, result;
> + u16 floor_value, ceil_value;
> +
> + if (!lut_size)
> + return channel_value;
> +
> + if (lut_size == 1)
> + return lut32_channel_value(&lut[0], channel);
> +
> + position = (u64)channel_value * (lut_size - 1);
> + index = position / U16_MAX;
> +
> + if (index >= lut_size - 1)
> + return lut32_channel_value(&lut[lut_size - 1], channel);
> +
> + fraction = position - (u64)index * U16_MAX;
> +
> + floor_value = lut32_channel_value(&lut[index], channel);
> + ceil_value = lut32_channel_value(&lut[index + 1], channel);
> +
> + delta = (s64)ceil_value - (s64)floor_value;
> + result = (s64)floor_value +
> + DIV_ROUND_CLOSEST(delta * fraction, (s64)U16_MAX);
[Severity: High]
Do the 64-bit divisions in apply_lut32_to_channel_value() break 32-bit
builds?
position is u64 and delta is s64, so dividing position by U16_MAX with /
and dividing delta * fraction by (s64)U16_MAX with DIV_ROUND_CLOSEST() emit
__udivdi3 and __divdi3 libcalls on 32-bit architectures, failing at link or
modpost time when CONFIG_DRM_VKMS is enabled. Using helpers from
linux/math64.h such as div_u64_rem() and DIV_S64_ROUND_CLOSEST() avoids raw
64-bit divisions.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261128-colorop-v1-0-dd79919f822b@gmail.com?part=4
next prev parent reply other threads:[~2026-11-28 17:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 17:15 [PATCH 0/7] drm/vkms: complete the plane color pipeline Oarora Etimis
2026-11-28 17:15 ` [PATCH 1/7] drm/vkms: add the colorops of a plane that is being enabled Oarora Etimis
2026-11-28 17:15 ` [PATCH 2/7] drm/vkms: free the colorop whose initialization failed Oarora Etimis
2026-11-28 17:27 ` sashiko-bot
2026-11-28 17:15 ` [PATCH 3/7] drm/vkms: use the colorop states of the state being composed Oarora Etimis
2026-11-28 17:31 ` sashiko-bot
2026-11-28 17:15 ` [PATCH 4/7] drm/vkms: add a programmable 1D LUT colorop Oarora Etimis
2026-11-28 17:25 ` sashiko-bot [this message]
2026-11-28 17:15 ` [PATCH 5/7] drm/vkms: add a 3D " Oarora Etimis
2026-11-28 17:34 ` sashiko-bot
2026-11-28 17:15 ` [PATCH 6/7] drm/vkms: add a multiplier colorop Oarora Etimis
2026-11-28 17:31 ` sashiko-bot
2026-11-28 17:15 ` [PATCH 7/7] drm/vkms: add KUnit coverage for the 3D LUT and multiplier colorops Oarora Etimis
2026-11-29 12:37 ` [PATCH 0/7] drm/vkms: complete the plane color pipeline Louis Chauvet
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-238876@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=oaroraetimis@gmail.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 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.