freedreno/a3xx+a4xx: fix potential null ptr deref
authorRob Clark <robclark@freedesktop.org>
Thu, 2 Jun 2016 15:42:25 +0000 (11:42 -0400)
committerRob Clark <robclark@freedesktop.org>
Thu, 2 Jun 2016 19:44:07 +0000 (15:44 -0400)
Coverity spotted the a3xx case (not sure why not the a4xx).

CID 1362452

Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/a3xx/fd3_gmem.c
src/gallium/drivers/freedreno/a4xx/fd4_gmem.c

index 81a613fa87028ad21a6ff09cf08c4a2518683734..7b96d5eaee2659e0c75d5af43646810adda25eff 100644 (file)
@@ -79,7 +79,8 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs,
                        if (rsc->stencil) {
                                rsc = rsc->stencil;
                                pformat = rsc->base.b.format;
-                               bases++;
+                               if (bases)
+                                       bases++;
                        }
                        slice = fd_resource_slice(rsc, psurf->u.tex.level);
                        format = fd3_pipe2color(pformat);
index c6fbf1c1d39fd46b07fccbd0f4d81ec5feebf0de..e2115454d8682100c154b2688873c9cecee1faeb 100644 (file)
@@ -80,7 +80,8 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs,
                        if (rsc->stencil) {
                                rsc = rsc->stencil;
                                pformat = rsc->base.b.format;
-                               bases++;
+                               if (bases)
+                                       bases++;
                        }
 
                        slice = fd_resource_slice(rsc, psurf->u.tex.level);