All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Oarora Etimis" <oaroraetimis@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 6/7] drm/vkms: add a multiplier colorop
Date: Sat, 28 Nov 2026 17:31:24 +0000	[thread overview]
Message-ID: <sashiko-outbox-238882@kernel.org> (raw)
In-Reply-To: <20261128-colorop-v1-6-dd79919f822b@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/vkms: NULL deref in vkms_initialize_color_pipeline()
  error cleanup
- [Medium] drm/vkms: raw 64-bit divisions in LUT helpers break 32-bit
  builds
--

commit c2a8c1681a0dfb65c3b0d103de4cd4216ec820ce
Author: Oarora Etimis <oaroraetimis@gmail.com>

drm/vkms: add a multiplier colorop

This commit adds a DRM_COLOROP_MULTIPLIER color operation to the VKMS plane
color pipeline and implements per-channel S31.32 sign-magnitude gain scaling
in the composer.

> diff --git a/drivers/gpu/drm/vkms/vkms_colorop.c b/drivers/gpu/drm/vkms/vkms_colorop.c
> index cceb9acca0da0..1e1e470be4dda 100644
> --- a/drivers/gpu/drm/vkms/vkms_colorop.c
> +++ b/drivers/gpu/drm/vkms/vkms_colorop.c
> @@ -157,6 +157,23 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
>  
>  	drm_colorop_set_next_property(ops[i - 1], ops[i]);
>  
> +	i++;
> +
> +	/* 8th op: multiplier */
> +	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_mult_init(dev, ops[i], plane, &vkms_colorop_funcs,
> +					  DRM_COLOROP_FLAG_ALLOW_BYPASS);
> +	if (ret)
> +		goto cleanup;

[Severity: Medium]
Can jumping to cleanup when drm_plane_colorop_mult_init() fails cause a NULL
pointer dereference in drm_colorop_cleanup(ops[i])?

drm_plane_colorop_mult_init() calls drm_plane_colorop_init(), which returns
early if drm_mode_object_add() fails, before setting colorop->dev or adding
colorop->head to config->colorop_list:

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);
	...
}

Because the cleanup label loops up to j <= i, it calls
drm_colorop_cleanup(ops[i]) on that partially initialized object, which
runs list_del(&colorop->head) on an unlinked list head and dereferences the
NULL colorop->dev pointer.

> diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
> index 51ac2ae75cf0c..b94c51264c647 100644
> --- a/drivers/gpu/drm/vkms/vkms_composer.c
> +++ b/drivers/gpu/drm/vkms/vkms_composer.c
> @@ -365,6 +365,17 @@ VISIBLE_IF_KUNIT void apply_3dlut_to_pixel(struct pixel_argb_s32 *pixel,
>  }
>  EXPORT_SYMBOL_IF_KUNIT(apply_3dlut_to_pixel);

[Severity: Medium]
Do the raw 64-bit divisions in apply_lut32_to_channel_value() and
apply_3dlut_to_channel_value() break 32-bit builds with undefined references
to __udivdi3 and __divdi3?

Both helpers divide 64-bit values directly by U16_MAX instead of using 64-bit
division helpers such as div_u64() or DIV_ROUND_CLOSEST_ULL():

drivers/gpu/drm/vkms/vkms_composer.c:apply_lut32_to_channel_value() {
	...
	position = (u64)channel_value * (lut_size - 1);
	index = position / U16_MAX;
	...
	delta = (s64)ceil_value - (s64)floor_value;
	result = (s64)floor_value +
		 DIV_ROUND_CLOSEST(delta * fraction, (s64)U16_MAX);
	...
}

drivers/gpu/drm/vkms/vkms_composer.c:apply_3dlut_to_channel_value() {
	...
	position = (u64)r * max_index;
	r_index = position / U16_MAX;
	...
	position = (u64)g * max_index;
	g_index = position / U16_MAX;
	...
	position = (u64)b * max_index;
	b_index = position / U16_MAX;
	...
}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261128-colorop-v1-0-dd79919f822b@gmail.com?part=6

  reply	other threads:[~2026-11-28 17:31 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
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 [this message]
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-238882@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.