Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a1419bee authored by Xiaoke Wang's avatar Xiaoke Wang Committed by Greg Kroah-Hartman
Browse files

drm/msm/mdp5: check the return of kzalloc()



[ Upstream commit 047ae665577776b7feb11bd4f81f46627cff95e7 ]

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: default avatarXiaoke Wang <xkernel.wang@foxmail.com>
Reviewed-by: default avatarDmitry 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: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 80b188da
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -179,7 +179,10 @@ static void mdp5_plane_reset(struct drm_plane *plane)
		drm_framebuffer_put(plane->state->fb);
		drm_framebuffer_put(plane->state->fb);


	kfree(to_mdp5_plane_state(plane->state));
	kfree(to_mdp5_plane_state(plane->state));
	plane->state = NULL;
	mdp5_state = kzalloc(sizeof(*mdp5_state), GFP_KERNEL);
	mdp5_state = kzalloc(sizeof(*mdp5_state), GFP_KERNEL);
	if (!mdp5_state)
		return;


	/* assign default blend parameters */
	/* assign default blend parameters */
	mdp5_state->alpha = 255;
	mdp5_state->alpha = 255;