drm/omap: Potential NULL deref in omap_crtc_duplicate_state()

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

Fixes: 3dfeb631a1 ("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>
This commit is contained in:
Dan Carpenter 2017-08-11 23:16:06 +03:00 committed by Tomi Valkeinen
parent 4161f200ff
commit 2419672f4c
1 changed files with 4 additions and 2 deletions

View File

@ -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;