All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathieu OTHACEHE <m.othacehe@gmail.com>
To: johan@kernel.org, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	Mathieu OTHACEHE <m.othacehe@gmail.com>
Subject: [PATCH 1/3] USB: mxu11x0: fix memory leak on usb_serial private data
Date: Sun,  3 Jan 2016 15:25:59 +0100	[thread overview]
Message-ID: <1451831161-26792-2-git-send-email-m.othacehe@gmail.com> (raw)
In-Reply-To: <1451831161-26792-1-git-send-email-m.othacehe@gmail.com>

On nominal execution, private data allocated on port_probe and attach
are never freed. Add port_remove and release callbacks to free them
respectively.

Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
---
 drivers/usb/serial/mxu11x0.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/usb/serial/mxu11x0.c b/drivers/usb/serial/mxu11x0.c
index e3c3f57c..0fe7eab 100644
--- a/drivers/usb/serial/mxu11x0.c
+++ b/drivers/usb/serial/mxu11x0.c
@@ -328,6 +328,14 @@ static int mxu1_download_firmware(struct usb_serial *serial,
 	return 0;
 }
 
+static void mxu1_release(struct usb_serial *serial)
+{
+	struct mxu1_device *mxdev;
+
+	mxdev = usb_get_serial_data(serial);
+	kfree(mxdev);
+}
+
 static int mxu1_port_probe(struct usb_serial_port *port)
 {
 	struct mxu1_port *mxport;
@@ -368,6 +376,16 @@ static int mxu1_port_probe(struct usb_serial_port *port)
 	return 0;
 }
 
+static int mxu1_port_remove(struct usb_serial_port *port)
+{
+	struct mxu1_port *mxport;
+
+	mxport = usb_get_serial_port_data(port);
+	kfree(mxport);
+
+	return 0;
+}
+
 static int mxu1_startup(struct usb_serial *serial)
 {
 	struct mxu1_device *mxdev;
@@ -957,7 +975,9 @@ static struct usb_serial_driver mxu11x0_device = {
 	.id_table		= mxu1_idtable,
 	.num_ports		= 1,
 	.port_probe             = mxu1_port_probe,
+	.port_remove            = mxu1_port_remove,
 	.attach			= mxu1_startup,
+	.release                = mxu1_release,
 	.open			= mxu1_open,
 	.close			= mxu1_close,
 	.ioctl			= mxu1_ioctl,
-- 
2.6.2


  reply	other threads:[~2016-01-03 14:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-03 14:25 [PATCH 0/3] USB: mxu11x0: fixes and follow ups Mathieu OTHACEHE
2016-01-03 14:25 ` Mathieu OTHACEHE [this message]
2016-01-03 16:27   ` [PATCH 1/3] USB: mxu11x0: fix memory leak on usb_serial private data Johan Hovold
2016-01-03 14:26 ` [PATCH 2/3] USB: mxu11x0: clean device control commands Mathieu OTHACEHE
2016-01-03 16:33   ` Johan Hovold
2016-01-03 14:26 ` [PATCH 3/3] USB: mxu11x0: move firmware download and endpoint testing to probe callback Mathieu OTHACEHE
2016-01-03 16:45   ` Johan Hovold

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=1451831161-26792-2-git-send-email-m.othacehe@gmail.com \
    --to=m.othacehe@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.