xhci: Move allocating of command for new_dequeue_state to queue_set_tr_deq()

There are multiple reasons for this:

1) This fixes a missing check for xhci_alloc_command failing in
   xhci_handle_cmd_stop_ep()
2) This adds a warning when we cannot set the new dequeue state because of
   xhci_alloc_command failing
3) It puts the allocation of the command after the sanity checks in
   queue_set_tr_deq(), avoiding leaking the command if those fail
4) Since queue_set_tr_deq now owns the command it can free it if queue_command
   fails
5) It reduces code duplication

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Цей коміт міститься в:
Hans de Goede
2014-08-20 16:41:52 +03:00
зафіксовано Greg Kroah-Hartman
джерело fac1f48584
коміт 1e3452e3f0
3 змінених файлів з 23 додано та 20 видалено

Переглянути файл

@@ -2887,14 +2887,9 @@ void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci,
* issue a configure endpoint command later.
*/
if (!(xhci->quirks & XHCI_RESET_EP_QUIRK)) {
struct xhci_command *command;
/* Can't sleep if we're called from cleanup_halted_endpoint() */
command = xhci_alloc_command(xhci, false, false, GFP_ATOMIC);
if (!command)
return;
xhci_dbg_trace(xhci, trace_xhci_dbg_reset_ep,
"Queueing new dequeue state");
xhci_queue_new_dequeue_state(xhci, command, udev->slot_id,
xhci_queue_new_dequeue_state(xhci, udev->slot_id,
ep_index, ep->stopped_stream, &deq_state);
} else {
/* Better hope no one uses the input context between now and the