stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	alan@lxorguk.ukuu.org.uk, Johan Hovold <jhovold@gmail.com>
Subject: [ 20/34] USB: sierra: fix memory leak in probe error path
Date: Mon, 29 Oct 2012 13:07:51 -0700	[thread overview]
Message-ID: <20121029200422.799301912@linuxfoundation.org> (raw)
In-Reply-To: <20121029200420.550338074@linuxfoundation.org>

3.0-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <jhovold@gmail.com>

commit 084817d79399ab5ccab2f90a148b0369912a8369 upstream.

Move interface data allocation to attach so that it is deallocated on
errors in usb-serial probe.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/sierra.c |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -171,7 +171,6 @@ static int sierra_probe(struct usb_seria
 {
 	int result = 0;
 	struct usb_device *udev;
-	struct sierra_intf_private *data;
 	u8 ifnum;
 
 	udev = serial->dev;
@@ -199,11 +198,6 @@ static int sierra_probe(struct usb_seria
 		return -ENODEV;
 	}
 
-	data = serial->private = kzalloc(sizeof(struct sierra_intf_private), GFP_KERNEL);
-	if (!data)
-		return -ENOMEM;
-	spin_lock_init(&data->susp_lock);
-
 	return result;
 }
 
@@ -915,6 +909,7 @@ static void sierra_dtr_rts(struct usb_se
 static int sierra_startup(struct usb_serial *serial)
 {
 	struct usb_serial_port *port;
+	struct sierra_intf_private *intfdata;
 	struct sierra_port_private *portdata;
 	struct sierra_iface_info *himemoryp = NULL;
 	int i;
@@ -922,6 +917,14 @@ static int sierra_startup(struct usb_ser
 
 	dev_dbg(&serial->dev->dev, "%s\n", __func__);
 
+	intfdata = kzalloc(sizeof(*intfdata), GFP_KERNEL);
+	if (!intfdata)
+		return -ENOMEM;
+
+	spin_lock_init(&intfdata->susp_lock);
+
+	usb_set_serial_data(serial, intfdata);
+
 	/* Set Device mode to D0 */
 	sierra_set_power_state(serial->dev, 0x0000);
 
@@ -979,6 +982,7 @@ err:
 		portdata = usb_get_serial_port_data(serial->port[i]);
 		kfree(portdata);
 	}
+	kfree(intfdata);
 
 	return -ENOMEM;
 }



  parent reply	other threads:[~2012-10-29 20:07 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-29 20:07 [ 00/34] 3.0.50-stable review Greg Kroah-Hartman
2012-10-29 20:07 ` [ 01/34] gen_init_cpio: avoid stack overflow when expanding Greg Kroah-Hartman
2012-10-29 20:07 ` [ 02/34] fs/compat_ioctl.c: VIDEO_SET_SPU_PALETTE missing error check Greg Kroah-Hartman
2012-10-29 20:07 ` [ 03/34] drivers/rtc/rtc-imxdi.c: add missing spin lock initialization Greg Kroah-Hartman
2012-10-29 20:07 ` [ 04/34] genalloc: stop crashing the system when destroying a pool Greg Kroah-Hartman
2012-10-29 20:07 ` [ 05/34] ARM: 7559/1: smp: switch away from the idmap before updating init_mm.mm_count Greg Kroah-Hartman
2012-10-29 20:07 ` [ 06/34] SUNRPC: Get rid of the xs_error_report socket callback Greg Kroah-Hartman
2012-10-29 20:07 ` [ 07/34] SUNRPC: Clear the connect flag when socket state is TCP_CLOSE_WAIT Greg Kroah-Hartman
2012-10-29 20:07 ` [ 08/34] Revert "SUNRPC: Ensure we close the socket on EPIPE errors too..." Greg Kroah-Hartman
2012-10-29 20:07 ` [ 09/34] SUNRPC: Prevent races in xs_abort_connection() Greg Kroah-Hartman
2012-10-29 20:07 ` [ 10/34] sysfs: sysfs_pathname/sysfs_add_one: Use strlcat() instead of strcat() Greg Kroah-Hartman
2012-10-29 20:07 ` [ 11/34] ehci: fix Lucid nohandoff pci quirk to be more generic with BIOS versions Greg Kroah-Hartman
2012-10-29 20:07 ` [ 12/34] ehci: Add yet-another Lucid nohandoff pci quirk Greg Kroah-Hartman
2012-10-29 20:07 ` [ 13/34] usb-storage: add unusual_devs entry for Casio EX-N1 digital camera Greg Kroah-Hartman
2012-10-29 20:07 ` [ 14/34] usb hub: send clear_tt_buffer_complete events when canceling TT clear work Greg Kroah-Hartman
2012-10-29 20:07 ` [ 15/34] USB: whiteheat: fix memory leak in error path Greg Kroah-Hartman
2012-10-29 20:07 ` [ 16/34] USB: opticon: fix DMA from stack Greg Kroah-Hartman
2012-10-29 20:07 ` [ 17/34] USB: opticon: fix memory leak in error path Greg Kroah-Hartman
2012-10-29 20:07 ` [ 18/34] USB: serial: Fix memory leak in sierra_release() Greg Kroah-Hartman
2012-10-29 20:07 ` [ 19/34] USB: sierra: fix memory leak in attach error path Greg Kroah-Hartman
2012-10-29 20:07 ` Greg Kroah-Hartman [this message]
2012-10-29 20:07 ` [ 21/34] USB: mos7840: fix urb leak at release Greg Kroah-Hartman
2012-10-29 20:07 ` [ 22/34] USB: mos7840: fix port-device leak in error path Greg Kroah-Hartman
2012-10-29 20:07 ` [ 23/34] USB: mos7840: remove NULL-urb submission Greg Kroah-Hartman
2012-10-29 20:07 ` [ 24/34] USB: mos7840: remove invalid disconnect handling Greg Kroah-Hartman
2012-10-29 20:07 ` [ 25/34] xhci: Fix potential NULL ptr deref in command cancellation Greg Kroah-Hartman
2012-10-29 20:07 ` [ 26/34] vhost: fix mergeable bufs on BE hosts Greg Kroah-Hartman
2012-10-29 20:07 ` [ 27/34] ARM: at91/i2c: change id to let i2c-gpio work Greg Kroah-Hartman
2012-10-29 20:07 ` [ 28/34] mac80211: check if key has TKIP type before updating IV Greg Kroah-Hartman
2012-10-29 20:08 ` [ 29/34] bcma: fix unregistration of cores Greg Kroah-Hartman
2012-10-29 20:08 ` [ 30/34] cpufreq / powernow-k8: Remove usage of smp_processor_id() in preemptible code Greg Kroah-Hartman
2012-10-29 20:08 ` [ 31/34] x86, mm: Find_early_table_space based on ranges that are actually being mapped Greg Kroah-Hartman
2012-10-29 20:08 ` [ 32/34] x86, mm: Undo incorrect revert in arch/x86/mm/init.c Greg Kroah-Hartman
2012-10-29 20:08 ` [ 33/34] staging: comedi: amplc_pc236: fix invalid register access during detach Greg Kroah-Hartman
2012-10-29 20:08 ` [ 34/34] drm/i915: no lvds quirk for Zotac ZDBOX SD ID12/ID13 Greg Kroah-Hartman

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=20121029200422.799301912@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=jhovold@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@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).