[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <53D60E8F.6080208@suse.cz>
Date: Mon, 28 Jul 2014 10:49:19 +0200
From: Jiri Slaby <jslaby@...e.cz>
To: "xinhui.pan" <xinhuix.pan@...el.com>,
Greg KH <gregkh@...uxfoundation.org>
CC: "Zhang, Yanmin" <yanmin_zhang@...ux.intel.com>,
Peter Hurley <peter@...leysoftware.com>,
mnipxh <mnipxh@...il.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tty/n_gsm.c: fix a memory leak in gsmld_open
On 07/28/2014 10:14 AM, xinhui.pan wrote:
> 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.
Nice catch!
> --- a/drivers/tty/n_gsm.c
> +++ b/drivers/tty/n_gsm.c
> @@ -2382,7 +2383,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);
It is quite illogical to put the mux here. It should be in gsmld_open.
I.e. gsm_cleanup_mux here, mux_put there.
thanks,
--
js
suse labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists