aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Ivanov <anton.ivanov@cambridgegreys.com>2020-12-07 17:19:40 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-12-30 11:53:53 +0100
commitd26a4edda515450cb65e69ea38a4ef8d0c63b53c (patch)
tree562901ea6a4dc55951f1bdf01b21a14e17e59554
parent48628ec96d2ec572b0a44a8d078e7d80f2950ceb (diff)
downloadkernel_replicant_linux-d26a4edda515450cb65e69ea38a4ef8d0c63b53c.tar.gz
kernel_replicant_linux-d26a4edda515450cb65e69ea38a4ef8d0c63b53c.tar.bz2
kernel_replicant_linux-d26a4edda515450cb65e69ea38a4ef8d0c63b53c.zip
um: chan_xterm: Fix fd leak
[ Upstream commit 9431f7c199ab0d02da1482d62255e0b4621cb1b5 ] 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: b40997b872cd ("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>
-rw-r--r--arch/um/drivers/xterm.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/um/drivers/xterm.c b/arch/um/drivers/xterm.c
index fc7f1e746703..87ca4a47cd66 100644
--- a/arch/um/drivers/xterm.c
+++ b/arch/um/drivers/xterm.c
@@ -18,6 +18,7 @@
struct xterm_chan {
int pid;
int helper_pid;
+ int chan_fd;
char *title;
int device;
int raw;
@@ -33,6 +34,7 @@ static void *xterm_init(char *str, int device, const struct chan_opts *opts)
return NULL;
*data = ((struct xterm_chan) { .pid = -1,
.helper_pid = -1,
+ .chan_fd = -1,
.device = device,
.title = opts->xterm_title,
.raw = opts->raw } );
@@ -149,6 +151,7 @@ static int xterm_open(int input, int output, int primary, void *d,
goto out_kill;
}
+ data->chan_fd = fd;
new = xterm_fd(fd, &data->helper_pid);
if (new < 0) {
err = new;
@@ -206,6 +209,8 @@ static void xterm_close(int fd, void *d)
os_kill_process(data->helper_pid, 0);
data->helper_pid = -1;
+ if (data->chan_fd != -1)
+ os_close_file(data->chan_fd);
os_close_file(fd);
}