xhci-mem.c: Check for ring->first_seg != NULL
[pandora-kernel.git] / drivers / usb / host / xhci-mem.c
index 1c5c9ba..e4513ab 100644 (file)
@@ -112,18 +112,20 @@ void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring)
        struct xhci_segment *seg;
        struct xhci_segment *first_seg;
 
-       if (!ring || !ring->first_seg)
+       if (!ring)
                return;
-       first_seg = ring->first_seg;
-       seg = first_seg->next;
-       xhci_dbg(xhci, "Freeing ring at %p\n", ring);
-       while (seg != first_seg) {
-               struct xhci_segment *next = seg->next;
-               xhci_segment_free(xhci, seg);
-               seg = next;
+       if (ring->first_seg) {
+               first_seg = ring->first_seg;
+               seg = first_seg->next;
+               xhci_dbg(xhci, "Freeing ring at %p\n", ring);
+               while (seg != first_seg) {
+                       struct xhci_segment *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);
 }
 
@@ -1473,11 +1475,12 @@ void xhci_update_bw_info(struct xhci_hcd *xhci,
                        /* Added or changed endpoint */
                        bw_info->ep_interval = CTX_TO_EP_INTERVAL(
                                        le32_to_cpu(ep_ctx->ep_info));
-                       bw_info->mult = CTX_TO_EP_MULT(
-                                       le32_to_cpu(ep_ctx->ep_info));
-                       /* Number of packets is zero-based in the input context,
-                        * but we want one-based for the interval table.
+                       /* Number of packets and mult are zero-based in the
+                        * input context, but we want one-based for the
+                        * interval table.
                         */
+                       bw_info->mult = CTX_TO_EP_MULT(
+                                       le32_to_cpu(ep_ctx->ep_info)) + 1;
                        bw_info->num_packets = CTX_TO_MAX_BURST(
                                        le32_to_cpu(ep_ctx->ep_info2)) + 1;
                        bw_info->max_packet_size = MAX_PACKET_DECODED(
@@ -1666,18 +1669,10 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
 
 void xhci_urb_free_priv(struct xhci_hcd *xhci, struct urb_priv *urb_priv)
 {
-       int last;
-
-       if (!urb_priv)
-               return;
-
-       last = urb_priv->length - 1;
-       if (last >= 0) {
-               int     i;
-               for (i = 0; i <= last; i++)
-                       kfree(urb_priv->td[i]);
+       if (urb_priv) {
+               kfree(urb_priv->td[0]);
+               kfree(urb_priv);
        }
-       kfree(urb_priv);
 }
 
 void xhci_free_command(struct xhci_hcd *xhci,