launcher: Don't leak tty file descriptor on error

parent 325390e5
......@@ -275,7 +275,7 @@ setup_tty(struct weston_launcher *launcher, int tty)
weston_log("%s not a vt\n", tty_device);
weston_log("if running weston from ssh, "
"use --tty to specify a tty\n");
return -1;
goto err_close;
}
ret = ioctl(launcher->tty, KDGETMODE, &kd_mode);
......@@ -286,7 +286,7 @@ setup_tty(struct weston_launcher *launcher, int tty)
if (kd_mode != KD_TEXT) {
weston_log("%s is already in graphics mode, "
"is another display server running?\n", tty_device);
return -1;
goto err_close;
}
ret = ioctl(launcher->tty, VT_ACTIVATE, minor(buf.st_rdev));
......@@ -297,19 +297,19 @@ setup_tty(struct weston_launcher *launcher, int tty)
if (ioctl(launcher->tty, KDGKBMODE, &launcher->kb_mode)) {
weston_log("failed to read keyboard mode: %m\n");
return -1;
goto err_close;
}
if (ioctl(launcher->tty, KDSKBMUTE, 1) &&
ioctl(launcher->tty, KDSKBMODE, K_OFF)) {
weston_log("failed to set K_OFF keyboard mode: %m\n");
return -1;
goto err_close;
}
ret = ioctl(launcher->tty, KDSETMODE, KD_GRAPHICS);
if (ret) {
weston_log("failed to set KD_GRAPHICS mode on tty: %m\n");
return -1;
goto err_close;
}
mode.mode = VT_PROCESS;
......@@ -317,16 +317,20 @@ setup_tty(struct weston_launcher *launcher, int tty)
mode.acqsig = SIGUSR1;
if (ioctl(launcher->tty, VT_SETMODE, &mode) < 0) {
weston_log("failed to take control of vt handling\n");
return -1;
goto err_close;
}
loop = wl_display_get_event_loop(launcher->compositor->wl_display);
launcher->vt_source =
wl_event_loop_add_signal(loop, SIGUSR1, vt_handler, launcher);
if (!launcher->vt_source)
return -1;
goto err_close;
return 0;
err_close:
close(launcher->tty);
return -1;
}
int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment