diff options
author | Johan Hovold <jhovold@gmail.com> | 2012-10-25 04:29:18 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-10-25 12:37:13 -0400 |
commit | 084817d79399ab5ccab2f90a148b0369912a8369 (patch) | |
tree | 09984a11f16bd5b8d9d5c829f81a8c4799d9cde5 /drivers/usb | |
parent | 7e41f9bcdd2e813ea2a3c40db291d87ea06b559f (diff) |
USB: sierra: fix memory leak in probe error path
Move interface data allocation to attach so that it is deallocated on
errors in usb-serial probe.
Cc: <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/serial/sierra.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 2cb27e49d4ac..bb2ecaf3296b 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c | |||
@@ -161,7 +161,6 @@ static int sierra_probe(struct usb_serial *serial, | |||
161 | { | 161 | { |
162 | int result = 0; | 162 | int result = 0; |
163 | struct usb_device *udev; | 163 | struct usb_device *udev; |
164 | struct sierra_intf_private *data; | ||
165 | u8 ifnum; | 164 | u8 ifnum; |
166 | 165 | ||
167 | udev = serial->dev; | 166 | udev = serial->dev; |
@@ -188,11 +187,6 @@ static int sierra_probe(struct usb_serial *serial, | |||
188 | return -ENODEV; | 187 | return -ENODEV; |
189 | } | 188 | } |
190 | 189 | ||
191 | data = serial->private = kzalloc(sizeof(struct sierra_intf_private), GFP_KERNEL); | ||
192 | if (!data) | ||
193 | return -ENOMEM; | ||
194 | spin_lock_init(&data->susp_lock); | ||
195 | |||
196 | return result; | 190 | return result; |
197 | } | 191 | } |
198 | 192 | ||
@@ -885,11 +879,20 @@ static void sierra_dtr_rts(struct usb_serial_port *port, int on) | |||
885 | static int sierra_startup(struct usb_serial *serial) | 879 | static int sierra_startup(struct usb_serial *serial) |
886 | { | 880 | { |
887 | struct usb_serial_port *port; | 881 | struct usb_serial_port *port; |
882 | struct sierra_intf_private *intfdata; | ||
888 | struct sierra_port_private *portdata; | 883 | struct sierra_port_private *portdata; |
889 | struct sierra_iface_info *himemoryp = NULL; | 884 | struct sierra_iface_info *himemoryp = NULL; |
890 | int i; | 885 | int i; |
891 | u8 ifnum; | 886 | u8 ifnum; |
892 | 887 | ||
888 | intfdata = kzalloc(sizeof(*intfdata), GFP_KERNEL); | ||
889 | if (!intfdata) | ||
890 | return -ENOMEM; | ||
891 | |||
892 | spin_lock_init(&intfdata->susp_lock); | ||
893 | |||
894 | usb_set_serial_data(serial, intfdata); | ||
895 | |||
893 | /* Set Device mode to D0 */ | 896 | /* Set Device mode to D0 */ |
894 | sierra_set_power_state(serial->dev, 0x0000); | 897 | sierra_set_power_state(serial->dev, 0x0000); |
895 | 898 | ||
@@ -947,6 +950,7 @@ err: | |||
947 | portdata = usb_get_serial_port_data(serial->port[i]); | 950 | portdata = usb_get_serial_port_data(serial->port[i]); |
948 | kfree(portdata); | 951 | kfree(portdata); |
949 | } | 952 | } |
953 | kfree(intfdata); | ||
950 | 954 | ||
951 | return -ENOMEM; | 955 | return -ENOMEM; |
952 | } | 956 | } |