winsys/radeon: check null in radeon_cs_create_fence
authorJulien Isorce <julien.isorce@gmail.com>
Fri, 10 Mar 2017 17:16:05 +0000 (17:16 +0000)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 13 Mar 2017 16:17:30 +0000 (17:17 +0100)
Fixes the following segmentation fault:

radeon_drm_cs_add_buffer (bo=0x0) at radeon_drm_cs.c
  -> if (!bo->handle)
(gdb) bt
0  radeon_drm_cs_add_buffer (bo=0x0) at radeon_drm_cs.c
1  0x00007fffe73575de in radeon_cs_create_fence radeon_drm_cs.c
2  0x00007fffe7358c48 in radeon_drm_cs_flush radeon_drm_cs.c

Signed-off-by: Julien Isorce <jisorce@oblong.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/winsys/radeon/drm/radeon_drm_cs.c

index d431bfc11f424f34cd416a06be72c6e266ef0b47..1545fd826373751bed5ac2342eb451d51f56816d 100644 (file)
@@ -750,6 +750,9 @@ radeon_cs_create_fence(struct radeon_winsys_cs *rcs)
     /* Create a fence, which is a dummy BO. */
     fence = cs->ws->base.buffer_create(&cs->ws->base, 1, 1,
                                        RADEON_DOMAIN_GTT, RADEON_FLAG_HANDLE);
+    if (!fence)
+       return NULL;
+
     /* Add the fence as a dummy relocation. */
     cs->ws->base.cs_add_buffer(rcs, fence,
                               RADEON_USAGE_READWRITE, RADEON_DOMAIN_GTT,