提交 0e6c7f74 编写于 作者: K Kautuk Consul 提交者: Greg Kroah-Hartman

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: NKautuk Consul <consul.kautuk@gmail.com>
Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable@kernel.org
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 10d674a8
...@@ -112,18 +112,20 @@ void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring) ...@@ -112,18 +112,20 @@ void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring)
struct xhci_segment *seg; struct xhci_segment *seg;
struct xhci_segment *first_seg; struct xhci_segment *first_seg;
if (!ring || !ring->first_seg) if (!ring)
return; return;
first_seg = ring->first_seg; if (ring->first_seg) {
seg = first_seg->next; first_seg = ring->first_seg;
xhci_dbg(xhci, "Freeing ring at %p\n", ring); seg = first_seg->next;
while (seg != first_seg) { xhci_dbg(xhci, "Freeing ring at %p\n", ring);
struct xhci_segment *next = seg->next; while (seg != first_seg) {
xhci_segment_free(xhci, seg); struct xhci_segment *next = seg->next;
seg = next; xhci_segment_free(xhci, seg);
seg = next;
}
xhci_segment_free(xhci, first_seg);
ring->first_seg = NULL;
} }
xhci_segment_free(xhci, first_seg);
ring->first_seg = NULL;
kfree(ring); kfree(ring);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册