xhci: Add missing checks for xhci_alloc_command failure
authorHans de Goede <hdegoede@redhat.com>
Fri, 25 Jul 2014 20:01:21 +0000 (22:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Aug 2014 22:58:59 +0000 (15:58 -0700)
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-ring.c
drivers/usb/host/xhci.c

index 749fc68eb5c135ef648f27816bce14d87cee7f23..60fb52ae864b0ed15066d6073647224df7fd32ec 100644 (file)
@@ -1118,6 +1118,10 @@ static void xhci_handle_cmd_reset_ep(struct xhci_hcd *xhci, int slot_id,
        if (xhci->quirks & XHCI_RESET_EP_QUIRK) {
                struct xhci_command *command;
                command = xhci_alloc_command(xhci, false, false, GFP_ATOMIC);
+               if (!command) {
+                       xhci_warn(xhci, "WARN Cannot submit cfg ep: ENOMEM\n");
+                       return;
+               }
                xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
                                "Queueing configure endpoint command");
                xhci_queue_configure_endpoint(xhci, command,
index a0772d362e709ba120d5feda1f7774ff2fbb92f7..b6f21175b872fd0d300968a55e2750e0fd9c69c5 100644 (file)
@@ -1553,6 +1553,10 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
         */
        if (!(ep->ep_state & EP_HALT_PENDING)) {
                command = xhci_alloc_command(xhci, false, false, GFP_ATOMIC);
+               if (!command) {
+                       ret = -ENOMEM;
+                       goto done;
+               }
                ep->ep_state |= EP_HALT_PENDING;
                ep->stop_cmds_pending++;
                ep->stop_cmd_timer.expires = jiffies +