From 7550c2942bef2b24f8c447a6194272c80b173c6d Mon Sep 17 00:00:00 2001 From: Shilun Wan Date: Mon, 25 May 2020 15:00:25 +0800 Subject: [PATCH] drm/msm/shd: fix null pointer dereferenced Add one safe judging condition for the variable 'm' to avoid null pointer dereferenced. Change-Id: I0848b3e56f3d77f0783789b09b4b9e20955dc6a0 Signed-off-by: Shilun Wan --- drivers/gpu/drm/msm/shd/shd_drm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/msm/shd/shd_drm.c b/drivers/gpu/drm/msm/shd/shd_drm.c index 4e069760be0c..5799bb1fbfd8 100644 --- a/drivers/gpu/drm/msm/shd/shd_drm.c +++ b/drivers/gpu/drm/msm/shd/shd_drm.c @@ -616,6 +616,8 @@ static int shd_connector_get_modes(struct drm_connector *connector, drm_mode.vtotal = drm_mode.vsync_end; m = drm_mode_duplicate(disp->drm_dev, &drm_mode); + if (!m) + return 0; drm_mode_set_name(m); drm_mode_probed_add(connector, m); rc = shd_drm_update_edid_name(&edid, disp->name);