diff options
author | Paul Cercueil <paul@crapouillou.net> | 2019-12-10 15:41:38 +0100 |
---|---|---|
committer | Paul Cercueil <paul@crapouillou.net> | 2019-12-14 19:25:54 +0100 |
commit | 354b051c5dcbeb35bbfd5d54161364fc7a75a58a (patch) | |
tree | 9de31a74767f328d3a79bb8da5b3ba58aff3f582 | |
parent | dt-bindings: display/ingenic: Add compatible string for JZ4770 (diff) | |
download | linux-354b051c5dcbeb35bbfd5d54161364fc7a75a58a.tar.xz linux-354b051c5dcbeb35bbfd5d54161364fc7a75a58a.zip |
gpu/drm: ingenic: Avoid null pointer deference in plane atomic update
It is possible that there is no drm_framebuffer associated with a given
plane state.
v2: Handle drm_plane->state which can be NULL too
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20191210144142.33143-2-paul@crapouillou.net
# *** extracted tags ***
Acked-by: Sam Ravnborg <sam@ravnborg.org>
-rw-r--r-- | drivers/gpu/drm/ingenic/ingenic-drm.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c b/drivers/gpu/drm/ingenic/ingenic-drm.c index ec32e1c67335..43a015f33e97 100644 --- a/drivers/gpu/drm/ingenic/ingenic-drm.c +++ b/drivers/gpu/drm/ingenic/ingenic-drm.c @@ -372,14 +372,18 @@ static void ingenic_drm_plane_atomic_update(struct drm_plane *plane, struct ingenic_drm *priv = drm_plane_get_priv(plane); struct drm_plane_state *state = plane->state; unsigned int width, height, cpp; + dma_addr_t addr; - width = state->crtc->state->adjusted_mode.hdisplay; - height = state->crtc->state->adjusted_mode.vdisplay; - cpp = state->fb->format->cpp[plane->index]; + if (state && state->fb) { + addr = drm_fb_cma_get_gem_addr(state->fb, state, 0); + width = state->crtc->state->adjusted_mode.hdisplay; + height = state->crtc->state->adjusted_mode.vdisplay; + cpp = state->fb->format->cpp[plane->index]; - priv->dma_hwdesc->addr = drm_fb_cma_get_gem_addr(state->fb, state, 0); - priv->dma_hwdesc->cmd = width * height * cpp / 4; - priv->dma_hwdesc->cmd |= JZ_LCD_CMD_EOF_IRQ; + priv->dma_hwdesc->addr = addr; + priv->dma_hwdesc->cmd = width * height * cpp / 4; + priv->dma_hwdesc->cmd |= JZ_LCD_CMD_EOF_IRQ; + } } static void ingenic_drm_encoder_atomic_mode_set(struct drm_encoder *encoder, |