Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/msm: Fix dereference of pointer minor before null check

Currently the pointer minor is being dereferenced before it is null
checked, leading to a potential null pointer dereference issue. Fix this
by dereferencing the pointer only after it has been null checked. Also
Replace minor->dev with dev.

Fixes: 4f89cf40d01e ("drm/msm: bail out late_init_minor() if it is not a GPU device")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Patchwork: https://patchwork.freedesktop.org/patch/666259/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>

authored by

Colin Ian King and committed by
Rob Clark
d02d50cb 08c5b422

+7 -4
+7 -4
drivers/gpu/drm/msm/msm_debugfs.c
··· 325 325 326 326 static int late_init_minor(struct drm_minor *minor) 327 327 { 328 - struct drm_device *dev = minor->dev; 329 - struct msm_drm_private *priv = dev->dev_private; 328 + struct drm_device *dev; 329 + struct msm_drm_private *priv; 330 330 int ret; 331 331 332 332 if (!minor) 333 333 return 0; 334 + 335 + dev = minor->dev; 336 + priv = dev->dev_private; 334 337 335 338 if (!priv->gpu_pdev) 336 339 return 0; 337 340 338 341 ret = msm_rd_debugfs_init(minor); 339 342 if (ret) { 340 - DRM_DEV_ERROR(minor->dev->dev, "could not install rd debugfs\n"); 343 + DRM_DEV_ERROR(dev->dev, "could not install rd debugfs\n"); 341 344 return ret; 342 345 } 343 346 344 347 ret = msm_perf_debugfs_init(minor); 345 348 if (ret) { 346 - DRM_DEV_ERROR(minor->dev->dev, "could not install perf debugfs\n"); 349 + DRM_DEV_ERROR(dev->dev, "could not install perf debugfs\n"); 347 350 return ret; 348 351 } 349 352