Skip to contentSkip to conversation

usb: xhci: fix wild pointers in xhci_mem_cleanup

PATCH New Lu Baolu 1 participant 2 messages Mar 25, 2016

Subsystems (3)
lore
Share & tools
lore

Lu Baolu

author
#0 lore raw

PATCH 1/2 usb: xhci: fix wild pointers in xhci_mem_cleanup

This patch fixes some wild pointers produced by xhci_mem_cleanup. These wild pointers will cause system crash if xhci_mem_cleanup() is called twice.

---
 drivers/usb/host/xhci-mem.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/usb/host/xhci-mem.c +6 -0
index 80c1de2..bad0d1f 100644
@@ -1861,6 +1861,12 @@ no_bw:
 	kfree(xhci->rh_bw);
 	kfree(xhci->ext_caps);
 
+	xhci->usb2_ports = NULL;
+	xhci->usb3_ports = NULL;
+	xhci->port_array = NULL;
+	xhci->rh_bw = NULL;
+	xhci->ext_caps = NULL;
+
 	xhci->page_size = 0;
 	xhci->page_shift = 0;
 	xhci->bus_state[0].bus_suspended = 0;
Signature · 1 line
2.1.4
author
#1 lore raw

PATCH 2/2 usb: xhci: remove hardcoded gfp_t in xhci_mem_init

xhci_mem_init() should use @flags, instead of hardcode, for DMA memory allocation.

---
 drivers/usb/host/xhci-mem.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/host/xhci-mem.c +3 -3
index bad0d1f..7c2f884 100644
@@ -2365,8 +2365,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
 	 * Section 5.4.8 - doorbell array must be
 	 * "physically contiguous and 64-byte (cache line) aligned".
 	 */
-	xhci->dcbaa = dma_alloc_coherent(dev, sizeof(*xhci->dcbaa), &dma,
-			GFP_KERNEL);
+	xhci->dcbaa = dma_alloc_coherent(dev, sizeof(*xhci->dcbaa),
+					 &dma, flags);
 	if (!xhci->dcbaa)
 		goto fail;
 	memset(xhci->dcbaa, 0, sizeof *(xhci->dcbaa));
@@ -2462,7 +2462,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
 
 	xhci->erst.entries = dma_alloc_coherent(dev,
 			sizeof(struct xhci_erst_entry) * ERST_NUM_SEGS, &dma,
-			GFP_KERNEL);
+			flags);
 	if (!xhci->erst.entries)
 		goto fail;
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init,
Signature · 1 line
2.1.4