From: Greg KH <gregkh@linuxfoundation.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: hjk@linutronix.de, jirislaby@kernel.org, lee.jones@linaro.org,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] tty: serial: 8250: serial_cs: Fix a memory leak in error handling path
Date: Thu, 13 May 2021 16:19:07 +0200 [thread overview]
Message-ID: <YJ01W4zWfG601Sbv@kroah.com> (raw)
In-Reply-To: <562910a450cb86db7c2c4a4328a60e53ef95f504.1620548790.git.christophe.jaillet@wanadoo.fr>
On Sun, May 09, 2021 at 10:28:18AM +0200, Christophe JAILLET wrote:
> In the probe function, if the final 'serial_config()' fails, 'info' is
> leaking.
>
> Use 'devm_kzalloc' instead to fix the leak and simplify the .remove
> function.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> I've not been able to find a Fixes tag. All I know is that it is old!
> ---
> drivers/tty/serial/8250/serial_cs.c | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/serial_cs.c b/drivers/tty/serial/8250/serial_cs.c
> index 63ea9c4da3d5..d18c98e0d0b0 100644
> --- a/drivers/tty/serial/8250/serial_cs.c
> +++ b/drivers/tty/serial/8250/serial_cs.c
> @@ -310,7 +310,7 @@ static int serial_probe(struct pcmcia_device *link)
> dev_dbg(&link->dev, "serial_attach()\n");
>
> /* Create new serial device */
> - info = kzalloc(sizeof(*info), GFP_KERNEL);
> + info = devm_kzalloc(&link->dev, sizeof(*info), GFP_KERNEL);
Ick, let's not mix and only use some devm_ calls here, why not just fix
it up and free it in the error path?
thanks,
greg k-h
prev parent reply other threads:[~2021-05-13 14:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-09 8:28 [PATCH] tty: serial: 8250: serial_cs: Fix a memory leak in error handling path Christophe JAILLET
2021-05-13 14:19 ` Greg KH [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YJ01W4zWfG601Sbv@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=hjk@linutronix.de \
--cc=jirislaby@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).