sna: Cleanup allocation of sna_output after late syscall fail
authorChris Wilson <chris@chris-wilson.co.uk>
Sun, 13 Oct 2013 10:04:02 +0000 (11:04 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Sun, 13 Oct 2013 10:04:02 +0000 (11:04 +0100)
If the second syscall fails (presumably as a deferred allocation failure
check), cleanup the allocations made so far before reporting the
failure.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
src/sna/sna_display.c

index 27a4467..547ebd8 100644 (file)
@@ -2594,6 +2594,8 @@ sna_output_init(ScrnInfoPtr scrn, struct sna_mode *mode, int num)
        sna_output->prop_values = malloc(sizeof(uint64_t)*conn.count_props);
        sna_output->dpms_mode = DPMSModeOff;
 
+       conn.count_encoders = 0;
+
        conn.count_modes = 1;
        conn.modes_ptr = (uintptr_t)&dummy;
 
@@ -2602,7 +2604,7 @@ sna_output_init(ScrnInfoPtr scrn, struct sna_mode *mode, int num)
        conn.prop_values_ptr = (uintptr_t)sna_output->prop_values;
 
        if (drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_GETCONNECTOR, &conn))
-               return false;
+               goto cleanup;
 
        /* statically constructed property list */
        assert(sna_output->num_props == conn.count_props);