diff options
author | xinhui.pan <xinhuix.pan@intel.com> | 2014-07-28 16:14:52 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-08-01 16:04:54 -0700 |
commit | 5a64096700dc9761b57e767c9f0b740eb2cb84dd (patch) | |
tree | 4f61f7ef658e9775791730516f5ac81de7d47a59 /drivers/tty | |
parent | 8368d6a2b73900507ad7632b8057532d0c2ee07f (diff) |
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: xinhui.pan <xinhuiX.pan@intel.com>
Reported-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/n_gsm.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index d5f578fe3fa..152443ab144 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -2366,6 +2366,7 @@ static void gsmld_close(struct tty_struct *tty) static int gsmld_open(struct tty_struct *tty) { struct gsm_mux *gsm; + int ret; if (tty->ops->write == NULL) return -EINVAL; @@ -2380,7 +2381,13 @@ static int gsmld_open(struct tty_struct *tty) /* Attach the initial passive connection */ 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; } /** |