[RFC,1/6] drm/msm: fix null pointer dereference in msm_atomic_prepare_fb()

Submitted by Brian Masney on May 5, 2019, 1:04 p.m.

Details

Message ID 20190505130413.32253-2-masneyb@onstation.org
State New
Headers show
Series "ARM: qcom: initial Nexus 5 display support" ( rev: 1 ) in Freedreno

Not browsing as part of any series.

Commit Message

Brian Masney May 5, 2019, 1:04 p.m.
_msm_gem_new() calls msm_gem_new_impl() with a NULL reservation_object
struct. msm_atomic_prepare_fb() assumes that the reservation_object is
always set, and attempts to reference a NULL pointer. Correct this by
checking to see if this value is NULL.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/gpu/drm/msm/msm_atomic.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c
index f5b1256e32b6..0da80a93876a 100644
--- a/drivers/gpu/drm/msm/msm_atomic.c
+++ b/drivers/gpu/drm/msm/msm_atomic.c
@@ -56,10 +56,12 @@  int msm_atomic_prepare_fb(struct drm_plane *plane,
 		return 0;
 
 	obj = msm_framebuffer_bo(new_state->fb, 0);
-	msm_obj = to_msm_bo(obj);
-	fence = reservation_object_get_excl_rcu(msm_obj->resv);
 
-	drm_atomic_set_fence_for_plane(new_state, fence);
+	msm_obj = to_msm_bo(obj);
+	if (msm_obj->resv) {
+		fence = reservation_object_get_excl_rcu(msm_obj->resv);
+		drm_atomic_set_fence_for_plane(new_state, fence);
+	}
 
 	return msm_framebuffer_prepare(new_state->fb, kms->aspace);
 }