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 <[email protected]> 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/[email protected]?part=6
