Patch "usb: xhci: Handle error condition in xhci_stop_device()" has been added to the 3.18-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
usb: xhci: Handle error condition in xhci_stop_device()
to the 3.18-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
usb-xhci-handle-error-condition-in-xhci_stop_device.patch
and it can be found in the queue-3.18 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
b3207c65dfafae27e7c492cb9188c0dc0eeaf3fdMon Sep 17 00:00:00 2001
From: Mayank Rana <[email protected]>
Date: Fri, 6 Oct 2017 17:45:30 +0300
Subject: usb: xhci: Handle error condition in xhci_stop_device()
From: Mayank Rana <[email protected]>
commit b3207c65dfafae27e7c492cb9188c0dc0eeaf3fd upstream.
xhci_stop_device() calls xhci_queue_stop_endpoint() multiple times without checking the return value. xhci_queue_stop_endpoint() can return error if the HC is already halted or unable to queue commands. This can cause a deadlock condition as xhci_stop_device() would end up waiting indefinitely for a completion for the command that didn't get queued. Fix this by checking the return value and bailing out of xhci_stop_device() in case of error. This patch happens to fix potential memory leaks of the allocated command structures as well.
--- drivers/usb/host/xhci-hub.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
drivers/usb/host/xhci-hub.c +17 -5
@@ -293,15 +293,25 @@ static int xhci_stop_device(struct xhci_ GFP_NOWAIT);if (!command) {spin_unlock_irqrestore (&xhci->lock, flags); -xhci_free_command (xhci, cmd); -return -ENOMEM ; + ret = -ENOMEM ; + goto cmd_cleanup; + } + ret =xhci_queue_stop_endpoint (xhci, command, slot_id, + i, suspend); +if (ret) { +spin_unlock_irqrestore (&xhci->lock, flags); +xhci_free_command (xhci, command); + goto cmd_cleanup; } -xhci_queue_stop_endpoint (xhci, command, slot_id, i, - suspend); } } -xhci_queue_stop_endpoint (xhci, cmd, slot_id,0 , suspend); + ret =xhci_queue_stop_endpoint (xhci, cmd, slot_id,0 , suspend); +if (ret) { +spin_unlock_irqrestore (&xhci->lock, flags); + goto cmd_cleanup; + } +xhci_ring_cmd_db (xhci);spin_unlock_irqrestore (&xhci->lock, flags);
@@ -312,6 +322,8 @@ static int xhci_stop_device(struct xhci_xhci_warn (xhci,"Timeout while waiting for stop endpoint command\n" ); ret = -ETIME ; } + +cmd_cleanup:xhci_free_command (xhci, cmd);return ret; }
Patches currently in stable-queue which might be from [email protected] are
queue-3.18/usb-xhci-handle-error-condition-in-xhci_stop_device.patch