Browse Source

drm/omap: Potential NULL deref in omap_crtc_duplicate_state()

If the kmalloc() fails then we dereference "state" when we set
"state->zpos".

Fixes: 3dfeb631a15d ("drm/omap: Rework the rotation-on-crtc hack")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Dan Carpenter 8 năm trước cách đây
mục cha
commit
2419672f4c
1 tập tin đã thay đổi với 4 bổ sung2 xóa
  1. 4 2
      drivers/gpu/drm/omapdrm/omap_crtc.c

+ 4 - 2
drivers/gpu/drm/omapdrm/omap_crtc.c

@@ -589,8 +589,10 @@ omap_crtc_duplicate_state(struct drm_crtc *crtc)
 	current_state = to_omap_crtc_state(crtc->state);
 
 	state = kmalloc(sizeof(*state), GFP_KERNEL);
-	if (state)
-		__drm_atomic_helper_crtc_duplicate_state(crtc, &state->base);
+	if (!state)
+		return NULL;
+
+	__drm_atomic_helper_crtc_duplicate_state(crtc, &state->base);
 
 	state->zpos = current_state->zpos;
 	state->rotation = current_state->rotation;