OSDN Git Service

drm/msm: Fix NULL deref in adreno_load_gpu
authorArchit Taneja <architt@codeaurora.org>
Fri, 22 Dec 2017 10:11:13 +0000 (15:41 +0530)
committerRob Clark <robdclark@gmail.com>
Wed, 3 Jan 2018 14:36:17 +0000 (09:36 -0500)
commit9dcfbc182f1aac0aa5ea194733d21e67dd2ba1fd
tree072d22a5d030d425c8f5d02a4912514ec2714763
parent7ddae82e12593ff3d44e628c02fbfa765508aa48
drm/msm: Fix NULL deref in adreno_load_gpu

The msm/kms driver should work even if there is no GPU device specified
in DT. Currently, we get a NULL dereference crash in adreno_load_gpu
since the driver assumes that priv->gpu_pdev is non-NULL.

Perform an additional check on priv->gpu_pdev before trying to retrieve
the msm_gpu pointer from it.

v2: Incorporate Jordan's comments:
- Simplify the check to share the same error message.
- Use dev_err_once() to avoid an error message every time we open the
  drm device fd.

Fixes: eec874ce5ff1 (drm/msm/adreno: load gpu at probe/bind time)

Signed-off-by: Archit Taneja <architt@codeaurora.org>
Acked-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
drivers/gpu/drm/msm/adreno/adreno_device.c