From: Oliver Neukum Date: Mon, 13 Jul 2009 08:46:57 +0000 (+0200) Subject: Staging: serqt_usb2: fix memory leak in error case X-Git-Tag: v3.12-rc1~13720^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=de8f8bd63334fe2014be7d9ab3a81ce9b96e5d19;p=kernel%2Fkernel-generic.git 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c index f9ff9c2..0fdf8c6 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);