[PATCH 4.17 52/66] usb: xhci: Fix memory leak in xhci_endpoint_reset()

From: Greg Kroah-Hartman
Date: Fri Jul 27 2018 - 05:50:28 EST


4.17-stable review patch. If anyone has any objections, please let me know.

------------------

From: Zheng Xiaowei <zhengxiaowei@xxxxxxxxxxxxx>

commit d89b7664f76047e7beca8f07e86f2ccfad085a28 upstream.

If td_list is not empty the cfg_cmd will not be freed,
call xhci_free_command to free it.

Signed-off-by: Zheng Xiaowei <zhengxiaowei@xxxxxxxxxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx>
Signed-off-by: Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
drivers/usb/host/xhci.c | 1 +
1 file changed, 1 insertion(+)

--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -2981,6 +2981,7 @@ static void xhci_endpoint_reset(struct u
if (!list_empty(&ep->ring->td_list)) {
dev_err(&udev->dev, "EP not empty, refuse reset\n");
spin_unlock_irqrestore(&xhci->lock, flags);
+ xhci_free_command(xhci, cfg_cmd);
goto cleanup;
}
xhci_queue_stop_endpoint(xhci, stop_cmd, udev->slot_id, ep_index, 0);