xhci: fix placement of call to usb_disabled()
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 31 Jan 2016 19:11:58 +0000 (11:11 -0800)
committerDanny Wood <danwood76@gmail.com>
Tue, 29 Jan 2019 13:11:19 +0000 (13:11 +0000)
In the backport of 1eaf35e4dd592c59041bc1ed3248c46326da1f5f, the call to
usb_disabled() was too late, after we had already done some allocation.
Move that call to the top of the function instead, making the logic
match what is intended and is in the original patch.

Reported-by: Luis Henriques <luis.henriques@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci.c

index 686211bce6d71f3128a6636ac946bc3362e04237..ded948d9fbb0e4044683ea3e6284aeeac8a40d90 100644 (file)
@@ -4782,6 +4782,9 @@ static int __init xhci_hcd_init(void)
 {
        int retval;
 
+       if (usb_disabled())
+               return -ENODEV;
+
        retval = xhci_register_pci();
        if (retval < 0) {
                printk(KERN_DEBUG "Problem registering PCI driver.");
@@ -4810,9 +4813,6 @@ static int __init xhci_hcd_init(void)
        /* xhci_run_regs has eight fields and embeds 128 xhci_intr_regs */
        BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8);
 
-       if (usb_disabled())
-               return -ENODEV;
-
        return 0;
 unreg_pci:
        xhci_unregister_pci();