Skip to content

Commit 047ae66

Browse files
x2018robclark
authored andcommitted
drm/msm/mdp5: check the return of kzalloc()
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@foxmail.com> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Patchwork: https://patchwork.freedesktop.org/patch/481055/ Link: https://lore.kernel.org/r/tencent_8E2A1C78140EE1784AB2FF4B2088CC0AB908@qq.com Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Signed-off-by: Rob Clark <robdclark@chromium.org>
1 parent 537fef8 commit 047ae66

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ static void mdp5_plane_reset(struct drm_plane *plane)
9191
__drm_atomic_helper_plane_destroy_state(plane->state);
9292

9393
kfree(to_mdp5_plane_state(plane->state));
94+
plane->state = NULL;
9495
mdp5_state = kzalloc(sizeof(*mdp5_state), GFP_KERNEL);
96+
if (!mdp5_state)
97+
return;
9598

9699
if (plane->type == DRM_PLANE_TYPE_PRIMARY)
97100
mdp5_state->base.zpos = STAGE_BASE;

0 commit comments

Comments
 (0)