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>
This commit is contained in:
Oliver Neukum 2009-07-13 10:46:57 +02:00 committed by Greg Kroah-Hartman
parent f3a756883a
commit de8f8bd633

View file

@ -738,6 +738,11 @@ static int qt_startup(struct usb_serial *serial)
if (!qt_port) { if (!qt_port) {
dbg("%s: kmalloc for quatech_port (%d) failed!.", dbg("%s: kmalloc for quatech_port (%d) failed!.",
__func__, i); __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; return -ENOMEM;
} }
spin_lock_init(&qt_port->lock); spin_lock_init(&qt_port->lock);