From: Paul Cercueil <paul@crapouillou.net> To: David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch> Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Paul Cercueil <paul@crapouillou.net> Subject: [PATCH v2 2/6] gpu/drm: ingenic: Avoid null pointer deference in plane atomic update Date: Tue, 10 Dec 2019 15:41:38 +0100 [thread overview] Message-ID: <20191210144142.33143-2-paul@crapouillou.net> (raw) In-Reply-To: <20191210144142.33143-1-paul@crapouillou.net> 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> --- drivers/gpu/drm/ingenic/ingenic-drm.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c b/drivers/gpu/drm/ingenic/ingenic-drm.c index 2e2ed653e9c6..f156f245fdec 100644 --- a/drivers/gpu/drm/ingenic/ingenic-drm.c +++ b/drivers/gpu/drm/ingenic/ingenic-drm.c @@ -371,14 +371,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, -- 2.24.0
WARNING: multiple messages have this Message-ID (diff)
From: Paul Cercueil <paul@crapouillou.net> To: David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch> Cc: Paul Cercueil <paul@crapouillou.net>, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/6] gpu/drm: ingenic: Avoid null pointer deference in plane atomic update Date: Tue, 10 Dec 2019 15:41:38 +0100 [thread overview] Message-ID: <20191210144142.33143-2-paul@crapouillou.net> (raw) In-Reply-To: <20191210144142.33143-1-paul@crapouillou.net> 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> --- drivers/gpu/drm/ingenic/ingenic-drm.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c b/drivers/gpu/drm/ingenic/ingenic-drm.c index 2e2ed653e9c6..f156f245fdec 100644 --- a/drivers/gpu/drm/ingenic/ingenic-drm.c +++ b/drivers/gpu/drm/ingenic/ingenic-drm.c @@ -371,14 +371,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, -- 2.24.0 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2019-12-10 14:42 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-12-10 14:41 [PATCH v2 1/6] dt-bindings: display/ingenic: Add compatible string for JZ4770 Paul Cercueil 2019-12-10 14:41 ` Paul Cercueil 2019-12-10 14:41 ` Paul Cercueil [this message] 2019-12-10 14:41 ` [PATCH v2 2/6] gpu/drm: ingenic: Avoid null pointer deference in plane atomic update Paul Cercueil 2019-12-10 14:41 ` [PATCH v2 3/6] gpu/drm: ingenic: Use the plane's src_[x,y] to configure DMA length Paul Cercueil 2019-12-10 14:41 ` [PATCH v2 3/6] gpu/drm: ingenic: Use the plane's src_[x, y] " Paul Cercueil 2019-12-10 14:41 ` [PATCH v2 4/6] gpu/drm: ingenic: Set max FB height to 4095 Paul Cercueil 2019-12-10 14:41 ` Paul Cercueil 2019-12-10 14:41 ` [PATCH v2 5/6] gpu/drm: ingenic: Check for display size in CRTC atomic check Paul Cercueil 2019-12-10 14:41 ` Paul Cercueil 2019-12-10 14:41 ` [PATCH v2 6/6] gpu/drm: ingenic: Add support for the JZ4770 Paul Cercueil 2019-12-10 14:41 ` Paul Cercueil 2019-12-14 10:54 ` [PATCH v2 1/6] dt-bindings: display/ingenic: Add compatible string for JZ4770 Sam Ravnborg 2019-12-14 10:54 ` Sam Ravnborg 2019-12-16 13:15 ` Ville Syrjälä 2019-12-16 13:15 ` Ville Syrjälä 2019-12-16 13:39 ` Paul Cercueil 2019-12-16 13:39 ` Paul Cercueil 2019-12-16 14:43 ` Ville Syrjälä 2019-12-16 14:43 ` Ville Syrjälä
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20191210144142.33143-2-paul@crapouillou.net \ --to=paul@crapouillou.net \ --cc=airlied@linux.ie \ --cc=daniel@ffwll.ch \ --cc=dri-devel@lists.freedesktop.org \ --cc=linux-kernel@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.