summaryrefslogtreecommitdiff
path: root/drivers/usb/serial/io_edgeport.c
diff options
context:
space:
mode:
authorChris Lund <docmax@gmail.com>2006-06-03 13:58:19 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2006-06-21 15:04:16 -0700
commitbfd5df3c0cf65bdf10a3a00baff036cb096140f6 (patch)
tree3b7835253e0b1f03bc42e323fe3988ee407c0e11 /drivers/usb/serial/io_edgeport.c
parent14f76cc7ab75b1c9db036dcd6b247e0dcc8952be (diff)
[PATCH] USB: free allocated memory on io_edgeport startup memory failure
While an Edgeport is allocating individual port structures, if kmalloc returns NULL, the serial structure is freed and -ENOMEM, but the ports allocated before the failure are not freed. This patch addresses that condition. Signed-off-by: Christopher Lund <docmax@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/io_edgeport.c')
-rw-r--r--drivers/usb/serial/io_edgeport.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index c28f1f6902c3..ed976ab56684 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -2730,7 +2730,7 @@ static int edge_startup (struct usb_serial *serial)
struct edgeport_serial *edge_serial;
struct edgeport_port *edge_port;
struct usb_device *dev;
- int i;
+ int i, j;
dev = serial->dev;
@@ -2794,6 +2794,10 @@ static int edge_startup (struct usb_serial *serial)
edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL);
if (edge_port == NULL) {
dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__);
+ for (j = 0; j < i; ++j) {
+ kfree (usb_get_serial_port_data(serial->port[j]));
+ usb_set_serial_port_data(serial->port[j], NULL);
+ }
usb_set_serial_data(serial, NULL);
kfree(edge_serial);
return -ENOMEM;