Skip to content

Commit d26a4ed

Browse files
kot-begemot-ukgregkh
authored andcommitted
um: chan_xterm: Fix fd leak
[ Upstream commit 9431f7c ] xterm serial channel was leaking a fd used in setting up the port helper This bug is prehistoric - it predates switching to git. The "fixes" header here is really just to mark all the versions we would like this to apply to which is "Anything from the Cretaceous period onwards". No dinosaurs were harmed in fixing this bug. Fixes: b40997b ("um: drivers/xterm.c: fix a file descriptor leak") Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 48628ec commit d26a4ed

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎arch/um/drivers/xterm.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
struct xterm_chan {
1919
int pid;
2020
int helper_pid;
21+
int chan_fd;
2122
char *title;
2223
int device;
2324
int raw;
@@ -33,6 +34,7 @@ static void *xterm_init(char *str, int device, const struct chan_opts *opts)
3334
return NULL;
3435
*data = ((struct xterm_chan) { .pid = -1,
3536
.helper_pid = -1,
37+
.chan_fd = -1,
3638
.device = device,
3739
.title = opts->xterm_title,
3840
.raw = opts->raw } );
@@ -149,6 +151,7 @@ static int xterm_open(int input, int output, int primary, void *d,
149151
goto out_kill;
150152
}
151153

154+
data->chan_fd = fd;
152155
new = xterm_fd(fd, &data->helper_pid);
153156
if (new < 0) {
154157
err = new;
@@ -206,6 +209,8 @@ static void xterm_close(int fd, void *d)
206209
os_kill_process(data->helper_pid, 0);
207210
data->helper_pid = -1;
208211

212+
if (data->chan_fd != -1)
213+
os_close_file(data->chan_fd);
209214
os_close_file(fd);
210215
}
211216

0 commit comments

Comments
 (0)