r600/drm: fix segfaults in winsys create failure path
authorKeith Whitwell <keithw@vmware.com>
Thu, 14 Oct 2010 15:42:38 +0000 (16:42 +0100)
committerDave Airlie <airlied@redhat.com>
Thu, 14 Oct 2010 22:33:00 +0000 (08:33 +1000)
Would try to destroy radeon->cman, radeon->kman both which were still
NULL.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/winsys/r600/drm/r600_drm.c

index 5f175a4df982030cc4bf27fd11cb0af6b99c5e6c..4916843fd6d31a1a5d7380cfe5956cde56503a58 100644 (file)
@@ -179,9 +179,15 @@ struct radeon *radeon_decref(struct radeon *radeon)
                return NULL;
        }
 
-       radeon->cman->destroy(radeon->cman);
-       radeon->kman->destroy(radeon->kman);
-       drmClose(radeon->fd);
+        if (radeon->cman)
+           radeon->cman->destroy(radeon->cman);
+
+        if (radeon->kman)
+           radeon->kman->destroy(radeon->kman);
+
+        if (radeon->fd >= 0)
+           drmClose(radeon->fd);
+
        free(radeon);
        return NULL;
 }