[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAA8EJprFBJeQQo79LOdJR0pA75wbzM64KRnPLHqLOGJ2KpJkEg@mail.gmail.com>
Date: Fri, 8 Apr 2022 15:21:42 +0300
From: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
To: xkernel.wang@...mail.com
Cc: robdclark@...il.com, quic_abhinavk@...cinc.com, sean@...rly.run,
airlied@...ux.ie, daniel@...ll.ch, linux-arm-msm@...r.kernel.org,
dri-devel@...ts.freedesktop.org, freedreno@...ts.freedesktop.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] drm/msm/mdp5: check the return of kzalloc()
On Thu, 7 Apr 2022 at 05:33, <xkernel.wang@...mail.com> wrote:
>
> From: Xiaoke Wang <xkernel.wang@...mail.com>
>
> kzalloc() is a memory allocation function which can return NULL when
> some internal memory errors happen. So it is better to check it to
> prevent potential wrong memory access.
>
> Besides, since mdp5_plane_reset() is void type, so we should better
> set `plane-state` to NULL after releasing it.
>
> Signed-off-by: Xiaoke Wang <xkernel.wang@...mail.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
> ---
> ChangeLog:
> v1->v2 simplify the patch and update the description.
> drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
> index c6b69af..50e8542 100644
> --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
> +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
> @@ -90,7 +90,10 @@ static void mdp5_plane_reset(struct drm_plane *plane)
> __drm_atomic_helper_plane_destroy_state(plane->state);
>
> kfree(to_mdp5_plane_state(plane->state));
> + plane->state = NULL;
> mdp5_state = kzalloc(sizeof(*mdp5_state), GFP_KERNEL);
> + if (!mdp5_state)
> + return;
>
> if (plane->type == DRM_PLANE_TYPE_PRIMARY)
> mdp5_state->base.zpos = STAGE_BASE;
> --
--
With best wishes
Dmitry
Powered by blists - more mailing lists