* [PATCH] drm/gma500: Fix potential NULL pointer dereference
@ 2018-06-25 12:18 Gustavo A. R. Silva
2018-06-26 13:28 ` Ville Syrjälä
0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2018-06-25 12:18 UTC (permalink / raw)
To: Patrik Jakobsson, David Airlie
Cc: dri-devel, linux-kernel, Gustavo A. R. Silva
fb is being dereferenced before it is null checked, hence there
is a potential null pointer dereference.
Fix this by moving the pointer dereference after fb has been
properly null checked at line 74: if (!fb)
Addresses-Coverity-ID: 1470169 ("Dereference before null check")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/gpu/drm/gma500/gma_display.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
index c8f071c..f767579 100644
--- a/drivers/gpu/drm/gma500/gma_display.c
+++ b/drivers/gpu/drm/gma500/gma_display.c
@@ -60,7 +60,7 @@ int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
struct drm_psb_private *dev_priv = dev->dev_private;
struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
struct drm_framebuffer *fb = crtc->primary->fb;
- struct gtt_range *gtt = to_gtt_range(fb->obj[0]);
+ struct gtt_range *gtt;
int pipe = gma_crtc->pipe;
const struct psb_offset *map = &dev_priv->regmap[pipe];
unsigned long start, offset;
@@ -76,6 +76,8 @@ int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
goto gma_pipe_cleaner;
}
+ gtt = to_gtt_range(fb->obj[0]);
+
/* We are displaying this buffer, make sure it is actually loaded
into the GTT */
ret = psb_gtt_pin(gtt);
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] drm/gma500: Fix potential NULL pointer dereference
2018-06-25 12:18 [PATCH] drm/gma500: Fix potential NULL pointer dereference Gustavo A. R. Silva
@ 2018-06-26 13:28 ` Ville Syrjälä
0 siblings, 0 replies; 2+ messages in thread
From: Ville Syrjälä @ 2018-06-26 13:28 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Patrik Jakobsson, David Airlie, linux-kernel, dri-devel
On Mon, Jun 25, 2018 at 07:18:44AM -0500, Gustavo A. R. Silva wrote:
> fb is being dereferenced before it is null checked, hence there
> is a potential null pointer dereference.
>
> Fix this by moving the pointer dereference after fb has been
> properly null checked at line 74: if (!fb)
I don't remember if set_base w/ fb==NULL is even legal. But as long as
the check is there this seems sane. Pushed to drm-misc-next. Thanks for
the patch.
>
> Addresses-Coverity-ID: 1470169 ("Dereference before null check")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> drivers/gpu/drm/gma500/gma_display.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
> index c8f071c..f767579 100644
> --- a/drivers/gpu/drm/gma500/gma_display.c
> +++ b/drivers/gpu/drm/gma500/gma_display.c
> @@ -60,7 +60,7 @@ int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
> struct drm_psb_private *dev_priv = dev->dev_private;
> struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
> struct drm_framebuffer *fb = crtc->primary->fb;
> - struct gtt_range *gtt = to_gtt_range(fb->obj[0]);
> + struct gtt_range *gtt;
> int pipe = gma_crtc->pipe;
> const struct psb_offset *map = &dev_priv->regmap[pipe];
> unsigned long start, offset;
> @@ -76,6 +76,8 @@ int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
> goto gma_pipe_cleaner;
> }
>
> + gtt = to_gtt_range(fb->obj[0]);
> +
> /* We are displaying this buffer, make sure it is actually loaded
> into the GTT */
> ret = psb_gtt_pin(gtt);
> --
> 2.7.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Ville Syrjälä
Intel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-26 13:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-25 12:18 [PATCH] drm/gma500: Fix potential NULL pointer dereference Gustavo A. R. Silva
2018-06-26 13:28 ` Ville Syrjälä
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox