aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorSergio Aguirre <sergio.a.aguirre.rodriguez@intel.com>2013-04-04 13:32:13 -0400
committerSarah Sharp <sarah.a.sharp@linux.intel.com>2013-05-24 12:14:47 -0400
commit331de00a64e5027365145bdf51da27b9ce15dfd5 (patch)
tree7ccf97556fec4986651e1a816b8801294908c2b9 /drivers/usb
parent2a0ebf80aa95cc758d4725f74a7016e992606a39 (diff)
xhci-mem: init list heads at the beginning of init
It is possible that we fail on xhci_mem_init, just before doing the INIT_LIST_HEAD, and calling xhci_mem_cleanup. Problem is that, the list_for_each_entry_safe macro, assumes list heads are initialized (not NULL), and dereferences their 'next' pointer, causing a kernel panic if this is not yet initialized. Let's protect from that by moving inits to the beginning. This patch should be backported to kernels as old as 3.2, that contain the commit 9574323c39d1f8359a04843075d89c9f32d8b7e6 "xHCI: test USB2 software LPM". Signed-off-by: Sergio Aguirre <sergio.a.aguirre.rodriguez@intel.com> Acked-by: David Cohen <david.a.cohen@intel.com> Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Cc: stable@vger.kernel.org
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/host/xhci-mem.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 2cfc465925bd..bda2c51a7c74 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -2256,6 +2256,9 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2256 u32 page_size, temp; 2256 u32 page_size, temp;
2257 int i; 2257 int i;
2258 2258
2259 INIT_LIST_HEAD(&xhci->lpm_failed_devs);
2260 INIT_LIST_HEAD(&xhci->cancel_cmd_list);
2261
2259 page_size = xhci_readl(xhci, &xhci->op_regs->page_size); 2262 page_size = xhci_readl(xhci, &xhci->op_regs->page_size);
2260 xhci_dbg(xhci, "Supported page size register = 0x%x\n", page_size); 2263 xhci_dbg(xhci, "Supported page size register = 0x%x\n", page_size);
2261 for (i = 0; i < 16; i++) { 2264 for (i = 0; i < 16; i++) {
@@ -2334,7 +2337,6 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2334 xhci->cmd_ring = xhci_ring_alloc(xhci, 1, 1, TYPE_COMMAND, flags); 2337 xhci->cmd_ring = xhci_ring_alloc(xhci, 1, 1, TYPE_COMMAND, flags);
2335 if (!xhci->cmd_ring) 2338 if (!xhci->cmd_ring)
2336 goto fail; 2339 goto fail;
2337 INIT_LIST_HEAD(&xhci->cancel_cmd_list);
2338 xhci_dbg(xhci, "Allocated command ring at %p\n", xhci->cmd_ring); 2340 xhci_dbg(xhci, "Allocated command ring at %p\n", xhci->cmd_ring);
2339 xhci_dbg(xhci, "First segment DMA is 0x%llx\n", 2341 xhci_dbg(xhci, "First segment DMA is 0x%llx\n",
2340 (unsigned long long)xhci->cmd_ring->first_seg->dma); 2342 (unsigned long long)xhci->cmd_ring->first_seg->dma);
@@ -2445,8 +2447,6 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2445 if (xhci_setup_port_arrays(xhci, flags)) 2447 if (xhci_setup_port_arrays(xhci, flags))
2446 goto fail; 2448 goto fail;
2447 2449
2448 INIT_LIST_HEAD(&xhci->lpm_failed_devs);
2449
2450 /* Enable USB 3.0 device notifications for function remote wake, which 2450 /* Enable USB 3.0 device notifications for function remote wake, which
2451 * is necessary for allowing USB 3.0 devices to do remote wakeup from 2451 * is necessary for allowing USB 3.0 devices to do remote wakeup from
2452 * U3 (device suspend). 2452 * U3 (device suspend).