aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorKautuk Consul <consul.kautuk@gmail.com>2011-09-19 19:53:12 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-09-20 15:40:31 -0400
commit0e6c7f746ea99089fb3263709075c20485a479ae (patch)
tree3b453455362557f872562ffac17c1d055c1caa2d /drivers/usb/host
parent10d674a82e553cb8a1f41027bb3c3e309b3f6804 (diff)
xhci-mem.c: Check for ring->first_seg != NULL
There are 2 situations wherein the xhci_ring* might not get freed: - When xhci_ring_alloc() -> xhci_segment_alloc() returns NULL and we goto the fail: label in xhci_ring_alloc. In this case, the ring will not get kfreed. - When the num_segs argument to xhci_ring_alloc is passed as 0 and we try to free the rung after that. ( This doesn't really happen as of now in the code but we seem to be entertaining num_segs=0 in xhci_ring_alloc ) This should be backported to kernels as old as 2.6.31. Signed-off-by: Kautuk Consul <consul.kautuk@gmail.com> Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/xhci-mem.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 94a8b28d602e..e4513ab015b4 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -112,18 +112,20 @@ void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring)
112 struct xhci_segment *seg; 112 struct xhci_segment *seg;
113 struct xhci_segment *first_seg; 113 struct xhci_segment *first_seg;
114 114
115 if (!ring || !ring->first_seg) 115 if (!ring)
116 return; 116 return;
117 first_seg = ring->first_seg; 117 if (ring->first_seg) {
118 seg = first_seg->next; 118 first_seg = ring->first_seg;
119 xhci_dbg(xhci, "Freeing ring at %p\n", ring); 119 seg = first_seg->next;
120 while (seg != first_seg) { 120 xhci_dbg(xhci, "Freeing ring at %p\n", ring);
121 struct xhci_segment *next = seg->next; 121 while (seg != first_seg) {
122 xhci_segment_free(xhci, seg); 122 struct xhci_segment *next = seg->next;
123 seg = next; 123 xhci_segment_free(xhci, seg);
124 seg = next;
125 }
126 xhci_segment_free(xhci, first_seg);
127 ring->first_seg = NULL;
124 } 128 }
125 xhci_segment_free(xhci, first_seg);
126 ring->first_seg = NULL;
127 kfree(ring); 129 kfree(ring);
128} 130}
129 131