提交 bfd5df3c 编写于 作者: C Chris Lund 提交者: Greg Kroah-Hartman

[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: NChristopher Lund <docmax@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 14f76cc7
...@@ -2730,7 +2730,7 @@ static int edge_startup (struct usb_serial *serial) ...@@ -2730,7 +2730,7 @@ static int edge_startup (struct usb_serial *serial)
struct edgeport_serial *edge_serial; struct edgeport_serial *edge_serial;
struct edgeport_port *edge_port; struct edgeport_port *edge_port;
struct usb_device *dev; struct usb_device *dev;
int i; int i, j;
dev = serial->dev; dev = serial->dev;
...@@ -2794,6 +2794,10 @@ static int edge_startup (struct usb_serial *serial) ...@@ -2794,6 +2794,10 @@ static int edge_startup (struct usb_serial *serial)
edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL); edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL);
if (edge_port == NULL) { if (edge_port == NULL) {
dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); 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); usb_set_serial_data(serial, NULL);
kfree(edge_serial); kfree(edge_serial);
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册