Kernel-Janitors Archive on
 help / color / Atom feed
From: Christophe JAILLET <>
	Christophe JAILLET <>
Subject: [PATCH v2] tty: serial: 8250: serial_cs: Fix a memory leak in error handling path
Date: Tue, 25 May 2021 21:44:04 +0200
Message-ID: <> (raw)

In the probe function, if the final 'serial_config()' fails, 'info' is

Add a resource handling path to free this memory.

Signed-off-by: Christophe JAILLET <>
v2: Use an error handling path instead of introducing some managed

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 | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/serial_cs.c b/drivers/tty/serial/8250/serial_cs.c
index 63ea9c4da3d5..3708114343b0 100644
--- a/drivers/tty/serial/8250/serial_cs.c
+++ b/drivers/tty/serial/8250/serial_cs.c
@@ -306,6 +306,7 @@ static int serial_resume(struct pcmcia_device *link)
 static int serial_probe(struct pcmcia_device *link)
 	struct serial_info *info;
+	int ret;
 	dev_dbg(&link->dev, "serial_attach()\n");
@@ -320,7 +321,15 @@ static int serial_probe(struct pcmcia_device *link)
 	if (do_sound)
 		link->config_flags |= CONF_ENABLE_SPKR;
-	return serial_config(link);
+	ret = serial_config(link);
+	if (ret)
+		goto free_info;
+	return 0;
+	kfree(info);
+	return ret;
 static void serial_detach(struct pcmcia_device *link)

                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Kernel-Janitors Archive on

Archives are clonable:
	git clone --mirror kernel-janitors/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernel-janitors kernel-janitors/ \
	public-inbox-index kernel-janitors

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone