diff options
author | Oliver Neukum <oliver@neukum.org> | 2009-07-13 10:46:57 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-07-28 23:07:10 +0200 |
commit | de8f8bd63334fe2014be7d9ab3a81ce9b96e5d19 (patch) | |
tree | 6de13d80966d2db57942038d1d61186611247321 | |
parent | Staging: serqt_usb2: add missing calls to tty_kref_put() (diff) | |
download | linux-de8f8bd63334fe2014be7d9ab3a81ce9b96e5d19.tar.xz linux-de8f8bd63334fe2014be7d9ab3a81ce9b96e5d19.zip |
Staging: serqt_usb2: fix memory leak in error case
a standard memory leak, as later allocations may fail even if prior
allocations did not. Then the prior allocations must be undone.
Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/serqt_usb2/serqt_usb2.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c index f9ff9c266780..0fdf8c6dc648 100644 --- a/drivers/staging/serqt_usb2/serqt_usb2.c +++ b/drivers/staging/serqt_usb2/serqt_usb2.c @@ -738,6 +738,11 @@ static int qt_startup(struct usb_serial *serial) if (!qt_port) { dbg("%s: kmalloc for quatech_port (%d) failed!.", __func__, i); + for(--i; i >= 0; i--) { + port = serial->port[i]; + kfree(usb_get_serial_port_data(port)); + usb_set_serial_port_data(port, NULL); + } return -ENOMEM; } spin_lock_init(&qt_port->lock); |