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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Apr 2018 10:31:05 +0000 (12:31 +0200)
commit3ca14535c781c54b25b0e786c43fefe12b58f14b
tree63a0bf9792d6c1f4da20dbec2cfc427f1176c693
parent70a6a6877a886b09d1ad72e4812da6e44b348772
drm/msm: Fix NULL deref in adreno_load_gpu

[ Upstream commit 9dcfbc182f1aac0aa5ea194733d21e67dd2ba1fd ]

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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/msm/adreno/adreno_device.c