1. 12 Nov, 2012 12 commits
    • Julius Werner's avatar
      xhci: fix null-pointer dereference when destroying half-built segment rings · 68e5254a
      Julius Werner authored
      xhci_alloc_segments_for_ring() builds a list of xhci_segments and links
      the tail to head at the end (forming a ring). When it bails out for OOM
      reasons half-way through, it tries to destroy its half-built list with
      xhci_free_segments_for_ring(), even though it is not a ring yet. This
      causes a null-pointer dereference upon hitting the last element.
      
      Furthermore, one of its callers (xhci_ring_alloc()) mistakenly believes
      the output parameters to be valid upon this kind of OOM failure, and
      calls xhci_ring_free() on them. Since the (incomplete) list/ring should
      already be destroyed in that case, this would lead to a use after free.
      
      This patch fixes those issues by having xhci_alloc_segments_for_ring()
      destroy its half-built, non-circular list manually and destroying the
      invalid struct xhci_ring in xhci_ring_alloc() with a plain kfree().
      
      This patch should be backported to kernels as old as 2.6.31, that
      contains the commit 0ebbab37 "USB: xhci:
      Ring allocation and initialization."
      
      A separate patch will need to be developed for kernels older than 3.4,
      since the ring allocation code was refactored in that kernel.
      Signed-off-by: default avatarJulius Werner <jwerner@chromium.org>
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable@vger.kernel.org
      68e5254a
    • Sarah Sharp's avatar
      xHCI: Fix TD Size calculation on 1.0 hosts. · 4525c0a1
      Sarah Sharp authored
      The xHCI 1.0 specification made a change to the TD Size field in TRBs.
      The value is now the number of packets that remain to be sent in the TD,
      not including this TRB.  The TD Size value for the last TRB in a TD must
      always be zero.
      
      The xHCI function xhci_v1_0_td_remainder() attempts to calculate this,
      but it gets it wrong.  First, it erroneously reuses the old
      xhci_td_remainder function, which will right shift the value by 10.  The
      xHCI 1.0 spec as of June 2011 says nothing about right shifting by 10.
      Second, it does not set the TD size for the last TRB in a TD to zero.
      
      Third, it uses roundup instead of DIV_ROUND_UP.  The total packet count
      is supposed to be the total number of bytes in this TD, divided by the
      max packet size, rounded up.  DIV_ROUND_UP is the right function to use
      in that case.
      
      With the old code, a TD on an endpoint with max packet size 1024 would
      be set up like so:
      TRB 1, TRB length = 600 bytes, TD size = 0
      TRB 1, TRB length = 200 bytes, TD size = 0
      TRB 1, TRB length = 100 bytes, TD size = 0
      
      With the new code, the TD would be set up like this:
      TRB 1, TRB length = 600 bytes, TD size = 1
      TRB 1, TRB length = 200 bytes, TD size = 1
      TRB 1, TRB length = 100 bytes, TD size = 0
      
      This commit should be backported to kernels as old as 3.0, that contain
      the commit 4da6e6f2 "xhci 1.0: Update TD
      size field format."
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Reported-by: default avatarChintan Mehta <chintan.mehta@sibridgetech.com>
      Reported-by: default avatarShimmer Huang <shimmering.h@gmail.com>
      Tested-by: default avatarBhavik Kothari <bhavik.kothari@sibridgetech.com>
      Tested-by: default avatarShimmer Huang <shimmering.h@gmail.com>
      Cc: stable@vger.kernel.org
      4525c0a1
    • Sarah Sharp's avatar
      xhci: Fix conditional check in bandwidth calculation. · 392a07ae
      Sarah Sharp authored
      David reports that at drivers/usb/host/xhci.c:2257:
      
      static bool xhci_is_sync_in_ep(unsigned int ep_type)
      {
          return (ep_type == ISOC_IN_EP || ep_type != INT_IN_EP);
      }
      
      The static analyser cppcheck says
      
      [linux-3.7-rc2/drivers/usb/host/xhci.c:2257]: (style) Redundant condition: If ep_type == 5, the comparison ep_type != 7 is always true.
      
      Maybe the original programmer intention was something like
      
      static bool xhci_is_sync_in_ep(unsigned int ep_type)
      {
          return (ep_type == ISOC_IN_EP || ep_type == INT_IN_EP);
      }
      
      Fix this.
      
      This patch should be backported to stable kernels as old as 3.2, that
      contain the commit 2b698999 "xhci: USB
      3.0 BW checking."
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Reported-by: default avatarDavid Binderman <dcb314@hotmail.com>
      Cc: stable@vger.kernel.org
      392a07ae
    • Sarah Sharp's avatar
      xhci: Avoid global symbol pollution with handshake. · 2611bd18
      Sarah Sharp authored
      Non-static xHCI driver symbols should start with the "xhci_" prefix, in
      order to avoid namespace pollution.  Rename the "handshake" function to
      "xhci_handshake".
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Reported-by: default avatarBen Hutchings <ben@decadent.org.uk>
      2611bd18
    • Alan Stern's avatar
      USB: report submission of active URBs · 2f02bc8a
      Alan Stern authored
      This patch (as1633) changes slightly the way usbcore handled
      submissions of URBs that are already active.  It will now return
      -EBUSY rather than -EINVAL, and it will call WARN_ONCE to draw
      people's attention to the bug.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2f02bc8a
    • Alan Stern's avatar
      USB: EHCI: bugfix: urb->hcpriv should not be NULL · 2656a9ab
      Alan Stern authored
      This patch (as1632b) fixes a bug in ehci-hcd.  The USB core uses
      urb->hcpriv to determine whether or not an URB is active; host
      controller drivers are supposed to set this pointer to a non-NULL
      value when an URB is queued.  However ehci-hcd sets it to NULL for
      isochronous URBs, which defeats the check in usbcore.
      
      In itself this isn't a big deal.  But people have recently found that
      certain sequences of actions will cause the snd-usb-audio driver to
      reuse URBs without waiting for them to complete.  In the absence of
      proper checking by usbcore, the URBs get added to their endpoint list
      twice.  This leads to list corruption and a system freeze.
      
      The patch makes ehci-hcd assign a meaningful value to urb->hcpriv for
      isochronous URBs.  Improving robustness always helps.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reported-by: default avatarArtem S. Tashkinov <t.artem@lycos.com>
      Reported-by: default avatarChristof Meerwald <cmeerw@cmeerw.org>
      CC: <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2656a9ab
    • Alan Stern's avatar
      USB: EHCI: miscellaneous cleanups for the library conversion · 1b36810e
      Alan Stern authored
      This patch (as1630) cleans up a few minor items resulting from the
      split-up of the ehci-hcd driver:
      
      	Remove the product_desc string from the ehci_driver_overrides
      	structure.  All drivers will use the generic "EHCI Host
      	Controller" string.  (This was requested by Felipe Balbi.)
      
      	Allow drivers to pass a NULL pointer to ehci_init_driver()
      	if they don't have to override any settings.
      
      	Remove a #define symbol that is no longer used from the
      	ChipIdea host driver.
      
      	Rename overrides to pci_overrides in ehci-pci.c, for
      	consistency with ehci-platform.c.
      
      	Mark the *_overrides structures as __initdata.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reviewed-by: default avatarFelipe Balbi <balbi@ti.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1b36810e
    • Alan Stern's avatar
      USB: fix endpoint-disabling for failed config changes · 36caff5d
      Alan Stern authored
      This patch (as1631) fixes a bug that shows up when a config change
      fails for a device under an xHCI controller.  The controller needs to
      be told to disable the endpoints that have been enabled for the new
      config.  The existing code does this, but before storing the
      information about which endpoints were enabled!  As a result, any
      second attempt to install the new config is doomed to fail because
      xhci-hcd will refuse to enable an endpoint that is already enabled.
      
      The patch optimistically initializes the new endpoints' device
      structures before asking the device to switch to the new config.  If
      the request fails then the endpoint information is already stored, so
      we can use usb_hcd_alloc_bandwidth() to disable the endpoints with no
      trouble.  The rest of the error path is slightly more complex now; we
      have to disable the new interfaces and call put_device() rather than
      simply deallocating them.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reported-and-tested-by: default avatarMatthias Schniedermeyer <ms@citd.de>
      CC: Sarah Sharp <sarah.a.sharp@linux.intel.com>
      CC: <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      36caff5d
    • Greg Kroah-Hartman's avatar
      Merge tag 'gadget-for-v3.8' of... · 7fd94bee
      Greg Kroah-Hartman authored
      Merge tag 'gadget-for-v3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next
      
      USB gadget patches from Felipe:
      "usb: gadget: patches for v3.8
      
      renesas_usbhs implements ->pullup() method, switches over
      to devm_request_irq(), adds support for DMA Engine and
      got a few miscelaneous cleanups.
      
      The NCM gadget got an endianness fix and the Ethernet
      gadget a frame size fix.
      
      We're finally removing the g_file_storage gadget and
      sticking to g_mass_storage and the new tcm_usb_gadget
      gadgets since that was a huge duplicaton of effort anyway.
      
      While removing g_file_storage, we also had to fix a bunch
      of defconfigs which were still pointing to the old gadget.
      
      There's a big series getting us closer to being able to
      introduce our configfs interface. The series converts
      functions into loadable modules which will, eventually,
      be registered to the configfs interface.
      
      Other than that there's the usual typo fixes and miscelaneous
      cleanups all over the place."
      7fd94bee
    • Greg Kroah-Hartman's avatar
      Merge tag 'dwc3-for-v3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next · 0f89fc3f
      Greg Kroah-Hartman authored
      USB dwc3 patches from Felipe:
      
      "usb: dwc3: patches for v3.8
      
      We can finaly drop HAVE_CLK dependency from exynos glue layer
      now that clk API provides no-op stubs when it's not linked
      into the kernel.
      
      We're also switching over event buffer allocation to devm_kzalloc()
      and moving the allocation out of dwc3_core_init() so that can be
      re-used when implementing PM support for v3.9.
      
      After the introduction of PLATFORM_DEVID_AUTO, we can also drop the
      homebrew platform device ID handling we had on dwc3 core and let
      driver core take care of that for us.
      
      Exynos glue layer learns about DeviceTree and drops platform_data
      support completely."
      0f89fc3f
    • Greg Kroah-Hartman's avatar
      Merge tag 'musb-for-v3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next · 3a3f2e50
      Greg Kroah-Hartman authored
      USB musb merge from Felipe:
      
      "usb: musb: patches for v3.8 merge window
      
      We have here the usual set of cleanups for the MUSB driver; a
      big set of patches converting platform_device_del() and
      platform_device_put() into platform_device_unregister().
      
      Another big set was applied converting to module_platform_driver()
      macro in order to reduce some boilerplate code from all glue
      layers.
      
      Other than that, we had a series fixing one known silicon errata
      where we couldn't read a few registers. In order to fix that
      we're now using shadow variables for reads and only writing
      to the registers which are known to break functionality when
      read."
      3a3f2e50
    • Greg Kroah-Hartman's avatar
      Merge tag 'xceiv-for-v3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into USB-next · 8e06c6a7
      Greg Kroah-Hartman authored
      Pull USB phy patches from Felipe:
      
      "usb: phy: patches for v3.8 merge window
      
      Not too many patches this time. First two patches are only
      cleanups where one of them switches over to module_platform_driver
      macro and the second removes inclusion of <mach/iomap.h> and is
      part of a bigger set of include cleanups from the Tegra folks.
      
      The only substantial change here is the addition of a driver
      for Renesas' R-Car USB Phy controller."
      8e06c6a7
  2. 09 Nov, 2012 2 commits
  3. 08 Nov, 2012 10 commits
  4. 06 Nov, 2012 11 commits
  5. 03 Nov, 2012 1 commit
  6. 02 Nov, 2012 4 commits