78 lines
2.1 KiB
Diff
78 lines
2.1 KiB
Diff
|
commit 4a74d5a4a45423752105f865a8310ce878b1790a
|
||
|
Author: Kristian Høgsberg <krh@bitplanet.net>
|
||
|
Date: Wed Oct 9 11:19:11 2013 -0700
|
||
|
|
||
|
launcher: Don't leak tty file descriptor on error
|
||
|
|
||
|
---
|
||
|
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
|
||
|
|
||
|
diff --git a/src/launcher-util.c b/src/launcher-util.c
|
||
|
index d90271f..8ab61f1 100644
|
||
|
--- a/src/launcher-util.c
|
||
|
+++ b/src/launcher-util.c
|
||
|
@@ -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
|