Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1300330
| From | Johan Hovold <johan@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/3] USB: mxu11x0: fix memory leak on usb_serial private data |
| Date | 2016-01-03 17:30 +0100 |
| Message-ID | <qMTHA-7Kr-5@gated-at.bofh.it> (permalink) |
| References | <qMRPr-6zf-7@gated-at.bofh.it> <qMRPr-6zf-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Sun, Jan 03, 2016 at 03:25:59PM +0100, Mathieu OTHACEHE wrote:
> On nominal execution, private data allocated on port_probe and attach
> are never freed. Add port_remove and release callbacks to free them
> respectively.
Ouch. I thought I'd vetted the driver for further memleaks but
apparently missed the most obvious ones.
> 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);
> +}
Please place this once after the matching attach (startup) callback.
> +
> 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;
Thanks,
Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH 1/3] USB: mxu11x0: fix memory leak on usb_serial private data Mathieu OTHACEHE <m.othacehe@gmail.com> - 2016-01-03 15:30 +0100 Re: [PATCH 1/3] USB: mxu11x0: fix memory leak on usb_serial private data Johan Hovold <johan@kernel.org> - 2016-01-03 17:30 +0100
csiph-web