Skip to content

Commit

Permalink
isp1760-hcd: fix possible memory leak if urb could not be enqueued
Browse files Browse the repository at this point in the history
After packetize_urb was called, we could still run into an error path
and will not hand over the prepared qtd to the qtd_list. Make sure to
free the prepared qtd in that case to avoid memory leaks.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Michael Grzeschik authored and Greg Kroah-Hartman committed Apr 18, 2012
1 parent 8cb2268 commit 8788fa0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/usb/host/isp1760-hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1562,11 +1562,14 @@ static int isp1760_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,

if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
retval = -ESHUTDOWN;
qtd_list_free(&new_qtds);
goto out;
}
retval = usb_hcd_link_urb_to_ep(hcd, urb);
if (retval)
if (retval) {
qtd_list_free(&new_qtds);
goto out;
}

qh = urb->ep->hcpriv;
if (qh) {
Expand All @@ -1584,6 +1587,7 @@ static int isp1760_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
if (!qh) {
retval = -ENOMEM;
usb_hcd_unlink_urb_from_ep(hcd, urb);
qtd_list_free(&new_qtds);
goto out;
}
list_add_tail(&qh->qh_list, ep_queue);
Expand Down

0 comments on commit 8788fa0

Please sign in to comment.