aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorKautuk Consul <consul.kautuk@gmail.com>2011-09-19 19:53:12 -0400
committerHerton Ronaldo Krzesinski <herton.krzesinski@canonical.com>2011-11-21 12:54:51 -0500
commit094f393e9b6c4485484f4a6839c4d3a00dd5b452 (patch)
tree87070021c8bb3a23b48f675fb3dc0c1766c9e96f /drivers/usb
parentfa3bb14b6324901650816a1be271780cb6a13e4a (diff)
xhci-mem.c: Check for ring->first_seg != NULL
BugLink: http://bugs.launchpad.net/bugs/890952 commit 0e6c7f746ea99089fb3263709075c20485a479ae upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Diffstat (limited to 'drivers/usb')
-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 2d671af6b7e..104620b3764 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -114,18 +114,20 @@ void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring)
114 struct xhci_segment *seg; 114 struct xhci_segment *seg;
115 struct xhci_segment *first_seg; 115 struct xhci_segment *first_seg;
116 116
117 if (!ring || !ring->first_seg) 117 if (!ring)
118 return; 118 return;
119 first_seg = ring->first_seg; 119 if (ring->first_seg) {
120 seg = first_seg->next; 120 first_seg = ring->first_seg;
121 xhci_dbg(xhci, "Freeing ring at %p\n", ring); 121 seg = first_seg->next;
122 while (seg != first_seg) { 122 xhci_dbg(xhci, "Freeing ring at %p\n", ring);
123 struct xhci_segment *next = seg->next; 123 while (seg != first_seg) {
124 xhci_segment_free(xhci, seg); 124 struct xhci_segment *next = seg->next;
125 seg = next; 125 xhci_segment_free(xhci, seg);
126 seg = next;
127 }
128 xhci_segment_free(xhci, first_seg);
129 ring->first_seg = NULL;
126 } 130 }
127 xhci_segment_free(xhci, first_seg);
128 ring->first_seg = NULL;
129 kfree(ring); 131 kfree(ring);
130} 132}
131 133