Commit 5a640967 authored by xinhui.pan's avatar xinhui.pan Committed by Greg Kroah-Hartman

tty/n_gsm.c: fix a memory leak in gsmld_open

If gsmld_attach_gsm fails, the gsm is not used anymore.
tty core will not call gsmld_close to do the cleanup work.
tty core just restore to the tty old ldisc.
That always causes memory leak.
Signed-off-by: default avatarxinhui.pan <xinhuiX.pan@intel.com>
Reported-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8368d6a2
...@@ -2366,6 +2366,7 @@ static void gsmld_close(struct tty_struct *tty) ...@@ -2366,6 +2366,7 @@ static void gsmld_close(struct tty_struct *tty)
static int gsmld_open(struct tty_struct *tty) static int gsmld_open(struct tty_struct *tty)
{ {
struct gsm_mux *gsm; struct gsm_mux *gsm;
int ret;
if (tty->ops->write == NULL) if (tty->ops->write == NULL)
return -EINVAL; return -EINVAL;
...@@ -2380,7 +2381,13 @@ static int gsmld_open(struct tty_struct *tty) ...@@ -2380,7 +2381,13 @@ static int gsmld_open(struct tty_struct *tty)
/* Attach the initial passive connection */ /* Attach the initial passive connection */
gsm->encoding = 1; gsm->encoding = 1;
return gsmld_attach_gsm(tty, gsm);
ret = gsmld_attach_gsm(tty, gsm);
if (ret != 0) {
gsm_cleanup_mux(gsm);
mux_put(gsm);
}
return ret;
} }
/** /**
......
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