summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiaoke Wang <xkernel.wang@foxmail.com>2022-04-07 10:31:51 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-04-27 13:15:30 +0200
commitf7fe17fa90e4d1c743fb0e6e6af2bd8b0a4a4a34 (patch)
tree39a6d82ecb1f70331e002790c0ea815ba9773de7
parentd0dc14c181a39191c55e6f889e1e6dc23cf977c0 (diff)
downloadlinux-stable-f7fe17fa90e4d1c743fb0e6e6af2bd8b0a4a4a34.tar.gz
linux-stable-f7fe17fa90e4d1c743fb0e6e6af2bd8b0a4a4a34.tar.bz2
linux-stable-f7fe17fa90e4d1c743fb0e6e6af2bd8b0a4a4a34.zip
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: 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index 4b22ac3413a1..1f9e3c5ea47d 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -197,7 +197,10 @@ static void mdp5_plane_reset(struct drm_plane *plane)
drm_framebuffer_unreference(plane->state->fb);
kfree(to_mdp5_plane_state(plane->state));
+ plane->state = NULL;
mdp5_state = kzalloc(sizeof(*mdp5_state), GFP_KERNEL);
+ if (!mdp5_state)
+ return;
/* assign default blend parameters */
mdp5_state->alpha = 255;