nouveau: avoid leaking screen on initialization fail
authorIlia Mirkin <imirkin@alum.mit.edu>
Sat, 13 Sep 2014 15:06:17 +0000 (11:06 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Sat, 13 Sep 2014 15:17:26 +0000 (11:17 -0400)
Reported by Coverity

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/mesa/drivers/dri/nouveau/nouveau_screen.c

index 766ae6f2f79e76767dc2d98fdd7a8e7d78eb876e..150dd8e9209a96a06cf8a161e8f3c0b32aec75e1 100644 (file)
@@ -95,6 +95,8 @@ nouveau_init_screen2(__DRIscreen *dri_screen)
        if (!screen)
                return NULL;
 
+       dri_screen->driverPrivate = screen;
+
        /* Open the DRM device. */
        ret = nouveau_device_wrap(dri_screen->fd, 0, &screen->device);
        if (ret) {
@@ -119,10 +121,11 @@ nouveau_init_screen2(__DRIscreen *dri_screen)
                dri_screen->max_gl_es1_version = 10;
                break;
        default:
-               assert(0);
+               nouveau_error("Unknown chipset: %02X\n",
+                             screen->device->chipset);
+               goto fail;
        }
 
-       dri_screen->driverPrivate = screen;
        dri_screen->extensions = nouveau_screen_extensions;
        screen->dri_screen = dri_screen;