Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/amd/display: NULL deref on kasprintf() failure in CRTC
  pipeline init
- [Medium] drm/amd/display: missing error unwind in
  amdgpu_dm_crtc_init()
--

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

drm/amd/display: enable post-blend CTM colorop

This commit initializes the AMD post-blend color pipeline on DCN 3.0 and
newer with a 3x4 CTM colorop and programs it when a CRTC color pipeline is
active.

Link: 
https://dri.freedesktop.org/docs/drm/gpu/amdgpu/display/display-manager.html#dc-color-capabilities-between-dcn-generations

> 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 c6bb9fec92175..dcd497b644c11 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
> @@ -305,3 +305,41 @@ int amdgpu_dm_initialize_default_pipeline(struct 
> drm_plane *plane, struct drm_pr
>       return amdgpu_dm_build_default_pipeline(dev, plane, hw_3d_lut, list);
>  }
>  EXPORT_IF_KUNIT(amdgpu_dm_initialize_default_pipeline);
> +
> +int amdgpu_dm_initialize_crtc_default_pipeline(struct drm_crtc *crtc,
> +                                            struct drm_prop_enum_list *list)
> +{
> +     struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS];
> +     struct drm_device *dev = crtc->dev;
> +     int ret;
> +     int i = 0;
> +
> +     memset(ops, 0, sizeof(ops));
> +
> +     /* 3x4 matrix */
> +     ops[i] = kzalloc_obj(struct drm_colorop);
> +     if (!ops[i]) {
> +             ret = -ENOMEM;
> +             goto cleanup;
> +     }
> +
> +     ret = drm_crtc_colorop_ctm_3x4_init(dev, ops[i], crtc, 
> &dm_colorop_funcs,
> +                                         DRM_COLOROP_FLAG_ALLOW_BYPASS);
> +     if (ret)
> +             goto cleanup;
> +
> +     list->type = ops[i]->base.id;
> +
> +     i++;
> +
> +     list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", 
> ops[0]->base.id);
> +
> +     return 0;

[Severity: Medium]
What happens if kasprintf() returns NULL here?  Unlike
amdgpu_dm_build_default_pipeline(), this returns 0 with list->name set to
NULL, so dm_crtc_init_colorops() passes pipelines[0].name to
drm_crtc_create_color_pipeline_property() -> drm_property_add_enum(),
causing a NULL pointer dereference in strlen(name) and skipping cleanup of
the initialized colorop.

[ ... ]

> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c 
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
> index 3e0128a29d775..af8be7f8784d3 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c

[ ... ]

> @@ -840,6 +878,10 @@ int amdgpu_dm_crtc_init(struct amdgpu_display_manager 
> *dm,
>  
>  #ifdef AMD_PRIVATE_COLOR
>       dm_crtc_additional_color_mgmt(&acrtc->base);
> +#else
> +     res = dm_crtc_init_colorops(&acrtc->base);
> +     if (res)
> +             return res;
>  #endif
>       return 0;

[Severity: Medium]
Should a failure in dm_crtc_init_colorops() clear
dm->adev->mode_info.crtcs[crtc_index] and jump to error_ism_fini instead of
returning directly?  Returning early skips amdgpu_dm_ism_flush(),
drm_crtc_cleanup(), drm_plane_cleanup(), and freeing acrtc and
cursor_plane, leaving the partially initialized CRTC registered in
mode_config and stored in mode_info.crtcs[crtc_index].

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

Reply via email to