]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.4.17/usb-sierra-fix-memory-leak-in-attach-error-path.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.4.17 / usb-sierra-fix-memory-leak-in-attach-error-path.patch
1 From 7e41f9bcdd2e813ea2a3c40db291d87ea06b559f Mon Sep 17 00:00:00 2001
2 From: Johan Hovold <jhovold@gmail.com>
3 Date: Thu, 25 Oct 2012 10:29:17 +0200
4 Subject: USB: sierra: fix memory leak in attach error path
5
6 From: Johan Hovold <jhovold@gmail.com>
7
8 commit 7e41f9bcdd2e813ea2a3c40db291d87ea06b559f upstream.
9
10 Make sure port private data is deallocated on errors in attach.
11
12 Signed-off-by: Johan Hovold <jhovold@gmail.com>
13 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
14
15 ---
16 drivers/usb/serial/sierra.c | 9 ++++++++-
17 1 file changed, 8 insertions(+), 1 deletion(-)
18
19 --- a/drivers/usb/serial/sierra.c
20 +++ b/drivers/usb/serial/sierra.c
21 @@ -936,7 +936,7 @@ static int sierra_startup(struct usb_ser
22 dev_dbg(&port->dev, "%s: kmalloc for "
23 "sierra_port_private (%d) failed!\n",
24 __func__, i);
25 - return -ENOMEM;
26 + goto err;
27 }
28 spin_lock_init(&portdata->lock);
29 init_usb_anchor(&portdata->active);
30 @@ -973,6 +973,13 @@ static int sierra_startup(struct usb_ser
31 }
32
33 return 0;
34 +err:
35 + for (--i; i >= 0; --i) {
36 + portdata = usb_get_serial_port_data(serial->port[i]);
37 + kfree(portdata);
38 + }
39 +
40 + return -ENOMEM;
41 }
42
43 static void sierra_release(struct usb_serial *serial)