tty: Clean up completely if switching vt fails
authorRob Bradford <rob@linux.intel.com>
Wed, 5 Dec 2012 18:47:08 +0000 (18:47 +0000)
committerKristian Høgsberg <krh@bitplanet.net>
Fri, 7 Dec 2012 03:32:37 +0000 (22:32 -0500)
The code under the "err" label closes the file descriptor and frees the
allocated memory.

src/tty.c

index 6d58aa5..05e5e20 100644 (file)
--- a/src/tty.c
+++ b/src/tty.c
@@ -174,7 +174,7 @@ tty_create(struct weston_compositor *compositor, tty_vt_func_t vt_func,
                if (ioctl(tty->fd, VT_ACTIVATE, tty->vt) < 0 ||
                    ioctl(tty->fd, VT_WAITACTIVE, tty->vt) < 0) {
                        weston_log("failed to swtich to new vt\n");
-                       return NULL;
+                       goto err;
                }
        }