[PATCH] drm/amd/display: Add NULL check for kzalloc in 'amdgpu_dm_atomic_commit_tail()'

Pillai, Aurabindo Aurabindo.Pillai at amd.com
Tue Jan 30 15:12:29 UTC 2024


[AMD Official Use Only - General]

Prefer drm_err instead of DRM_ERR: https://elixir.bootlin.com/linux/latest/source/include/drm/drm_print.h#L468

With or without that fixed, patch is

Reviewed-by: Aurabindo Pillai <aurabindo.pillai at amd.com>

--

Regards,
Jay
________________________________
From: SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM at amd.com>
Sent: Tuesday, January 30, 2024 4:45 AM
To: Siqueira, Rodrigo <Rodrigo.Siqueira at amd.com>; Pillai, Aurabindo <Aurabindo.Pillai at amd.com>
Cc: amd-gfx at lists.freedesktop.org <amd-gfx at lists.freedesktop.org>; Julia Lawall <julia.lawall at inria.fr>; Hung, Alex <Alex.Hung at amd.com>; Deucher, Alexander <Alexander.Deucher at amd.com>; Chung, ChiaHsuan (Tom) <ChiaHsuan.Chung at amd.com>
Subject: Re: [PATCH] drm/amd/display: Add NULL check for kzalloc in 'amdgpu_dm_atomic_commit_tail()'

+ Cc: Tom Chung <chiahsuan.chung at amd.com>

On 1/30/2024 2:11 PM, SHANMUGAM, SRINIVASAN wrote:
> Add a NULL check for the kzalloc call that allocates memory for
> dummy_updates in the amdgpu_dm_atomic_commit_tail function. Previously,
> if kzalloc failed to allocate memory and returned NULL, the code would
> attempt to use the NULL pointer.
>
> The fix is to check if kzalloc returns NULL, and if so, log an error
> message and skip the rest of the current loop iteration with the
> continue statement.  This prevents the code from attempting to use the
> NULL pointer.
>
> Cc: Julia Lawall <julia.lawall at inria.fr>
> Cc: Aurabindo Pillai <aurabindo.pillai at amd.com>
> Cc: Rodrigo Siqueira <rodrigo.siqueira at amd.com>
> Cc: Alex Hung <alex.hung at amd.com>
> Cc: Alex Deucher <alexander.deucher at amd.com>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam at amd.com>
> ---
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 0bf1bc7ced7d..8590c9f1dda6 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -9236,6 +9236,10 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
>                 * To fix this, DC should permit updating only stream properties.
>                 */
>                dummy_updates = kzalloc(sizeof(struct dc_surface_update) * MAX_SURFACES, GFP_ATOMIC);
> +             if (!dummy_updates) {
> +                     DRM_ERROR("Failed to allocate memory for dummy_updates.\n");
> +                     continue;
> +             }
>                for (j = 0; j < status->plane_count; j++)
>                        dummy_updates[j].surface = status->plane_states[0];
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20240130/2b81befd/attachment-0001.htm>


More information about the amd-gfx mailing list