Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/amd/display: leak of ops[i] on init failure in
  amdgpu_dm_initialize_crtc_default_pipeline()
- [Medium] drm/amd/display: unchecked kasprintf() in
  amdgpu_dm_initialize_crtc_default_pipeline()
--

commit a8178a6daf7c1cd1a2cd47ce46fa81a020bacd1b
Author: Melissa Wen <[email protected]>

drm/amd/display: add support to post-blend 1D-LUT colorop

This commit adds the Regamma 1D LUT colorop to the AMD CRTC post-blend
color pipeline and wires up its state handling in
__set_dm_crtc_colorop_regamma().

> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c 
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> index f5991f29973d5..8218a9cbad33b 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> @@ -350,6 +350,24 @@ int amdgpu_dm_initialize_crtc_default_pipeline(struct 
> drm_crtc *crtc,
>               drm_colorop_set_next_property(ops[i-1], ops[i]);
>  
>               i++;
> +
> +             /* 1D LUT - REGAMMA LUT */
> +             ops[i] = kzalloc_obj(*ops[0]);
> +             if (!ops[i]) {
> +                     ret = -ENOMEM;
> +                     goto cleanup;
> +             }
> +
> +             ret = drm_crtc_colorop_curve_1d_lut_init(dev, ops[i], crtc, 
> &dm_colorop_funcs,
> +                                                      MAX_COLOR_LUT_ENTRIES,
> +                                                      
> DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR,
> +                                                      
> DRM_COLOROP_FLAG_ALLOW_BYPASS);
> +             if (ret)
> +                     goto cleanup;

[Severity: Medium]
Can jumping to cleanup here leak ops[i] if
drm_crtc_colorop_curve_1d_lut_init() fails?

In drm_crtc_colorop_init() -> drm_common_colorop_init(), if
drm_mode_object_add() fails, the function returns before linking ops[i] into
config->colorop_list.  Because cleanup only calls
drm_colorop_pipeline_destroy(dev) to free colorops on config->colorop_list,
ops[i] is leaked.

> +
> +             drm_colorop_set_next_property(ops[i-1], ops[i]);
> +
> +             i++;
>       }
>  
>       list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", 
> ops[0]->base.id);

[Severity: Medium]
Should list->name be checked for NULL here, as in
amdgpu_dm_build_default_pipeline()?

If kasprintf() fails, amdgpu_dm_initialize_crtc_default_pipeline() skips
cleanup and returns 0 with list->name set to NULL.  The caller
dm_crtc_init_colorops() then passes the NULL pipeline name to
drm_crtc_create_color_pipeline_property(), causing a NULL pointer
dereference in strlen(name) inside drm_property_add_enum().

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=19

Reply via email to