Commit 5f62eab0 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: es2: fix memory leak in probe error path

In case a bulk-in transfer-buffer allocation failed during probe, we'd
currently leak the corresponding URB.
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent c9161d72
...@@ -1623,6 +1623,8 @@ static int ap_probe(struct usb_interface *interface, ...@@ -1623,6 +1623,8 @@ static int ap_probe(struct usb_interface *interface,
retval = -ENOMEM; retval = -ENOMEM;
goto error; goto error;
} }
cport_in->urb[i] = urb;
buffer = kmalloc(ES2_GBUF_MSG_SIZE_MAX, GFP_KERNEL); buffer = kmalloc(ES2_GBUF_MSG_SIZE_MAX, GFP_KERNEL);
if (!buffer) { if (!buffer) {
retval = -ENOMEM; retval = -ENOMEM;
...@@ -1634,7 +1636,7 @@ static int ap_probe(struct usb_interface *interface, ...@@ -1634,7 +1636,7 @@ static int ap_probe(struct usb_interface *interface,
cport_in->endpoint), cport_in->endpoint),
buffer, ES2_GBUF_MSG_SIZE_MAX, buffer, ES2_GBUF_MSG_SIZE_MAX,
cport_in_callback, hd); cport_in_callback, hd);
cport_in->urb[i] = urb;
cport_in->buffer[i] = buffer; cport_in->buffer[i] = buffer;
} }
} }
...@@ -1649,6 +1651,8 @@ static int ap_probe(struct usb_interface *interface, ...@@ -1649,6 +1651,8 @@ static int ap_probe(struct usb_interface *interface,
retval = -ENOMEM; retval = -ENOMEM;
goto error; goto error;
} }
es2->arpc_urb[i] = urb;
buffer = kmalloc(ARPC_IN_SIZE_MAX, GFP_KERNEL); buffer = kmalloc(ARPC_IN_SIZE_MAX, GFP_KERNEL);
if (!buffer) { if (!buffer) {
retval = -ENOMEM; retval = -ENOMEM;
...@@ -1661,7 +1665,6 @@ static int ap_probe(struct usb_interface *interface, ...@@ -1661,7 +1665,6 @@ static int ap_probe(struct usb_interface *interface,
buffer, ARPC_IN_SIZE_MAX, buffer, ARPC_IN_SIZE_MAX,
arpc_in_callback, es2); arpc_in_callback, es2);
es2->arpc_urb[i] = urb;
es2->arpc_buffer[i] = buffer; es2->arpc_buffer[i] = buffer;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment