1. 06 1月, 2017 3 次提交
    • B
      usb: musb: dsps: implement clear_ep_rxintr() callback · c48400ba
      Bin Liu 提交于
      During dma teardown for dequque urb, if musb load is high, musb might
      generate bogus rx ep interrupt even when the rx fifo is flushed. In such
      case any of the follow log messages could happen.
      
          musb_host_rx 1853: BOGUS RX2 ready, csr 0000, count 0
      
          musb_host_rx 1936: RX3 dma busy, csr 2020
      
      As mentioned in the current inline comment, clearing ep interrupt in the
      teardown path avoids the bogus interrupt, so implement clear_ep_rxintr()
      callback.
      
      This bug seems to be existing since the initial driver for musb support,
      but I only validated the fix back to v4.1, so only cc stable for v4.1+.
      
      cc: stable@vger.kernel.org # 4.1+
      Signed-off-by: NBin Liu <b-liu@ti.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c48400ba
    • B
      usb: musb: core: add clear_ep_rxintr() to musb_platform_ops · 6def85a3
      Bin Liu 提交于
      During dma teardown for dequque urb, if musb load is high, musb might
      generate bogus rx ep interrupt even when the rx fifo is flushed. In such
      case any of the follow log messages could happen.
      
      	musb_host_rx 1853: BOGUS RX2 ready, csr 0000, count 0
      
      	musb_host_rx 1936: RX3 dma busy, csr 2020
      
      As mentioned in the current inline comment, clearing ep interrupt in the
      teardown path avoids the bogus interrupt.
      
      Clearing ep interrupt is platform dependent, so this patch adds a
      platform callback to allow glue driver to clear the ep interrupt.
      
      This bug seems to be existing since the initial driver for musb support,
      but I only validated the fix back to v4.1, so only cc stable for v4.1+.
      
      cc: stable@vger.kernel.org # 4.1+
      Signed-off-by: NBin Liu <b-liu@ti.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6def85a3
    • G
      Merge tag 'usb-serial-4.10-rc3' of... · c8d204b3
      Greg Kroah-Hartman 提交于
      Merge tag 'usb-serial-4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-linus
      
      Johan writes:
      
      USB-serial fixes for v4.10-rc3
      
      These fixes address a number of long-standing issues in various
      USB-serial drivers which would lead to crashes should a malicious device
      lack the expected endpoints.
      
      Included are also a few related fixes, and a couple of unrelated ones
      that were found during my survey (e.g. a memleak and a
      sleep-while-atomic).
      
      A compiler warning revealed an error-handling issue in the new f81534
      driver which is also fixed.
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      c8d204b3
  2. 04 1月, 2017 35 次提交
    • J
      USB: serial: ti_usb_3410_5052: fix NULL-deref at open · ef079936
      Johan Hovold 提交于
      Fix NULL-pointer dereference in open() should a malicious device lack
      the expected endpoints:
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000030
      ..
      [<bf06a6b0>] (ti_open [ti_usb_3410_5052]) from [<bf02e118>] (serial_port_activate+0x68/0x98 [usbserial])
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      ef079936
    • J
      USB: serial: spcp8x5: fix NULL-deref at open · cc090924
      Johan Hovold 提交于
      Fix NULL-pointer dereference in open() should the device lack the
      expected endpoints:
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000030
      ...
      PC is at spcp8x5_open+0x30/0xd0 [spcp8x5]
      
      Fixes: 619a6f1d ("USB: add usb-serial spcp8x5 driver")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      cc090924
    • J
      USB: serial: quatech2: fix sleep-while-atomic in close · f09d1886
      Johan Hovold 提交于
      The write URB was being killed using the synchronous interface while
      holding a spin lock in close().
      
      Simply drop the lock and busy-flag update, something which would have
      been taken care of by the completion handler if the URB was in flight.
      
      Fixes: f7a33e60 ("USB: serial: add quatech2 usb to serial driver")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      f09d1886
    • J
      USB: serial: pl2303: fix NULL-deref at open · 76ab439e
      Johan Hovold 提交于
      Fix NULL-pointer dereference in open() should a type-0 or type-1 device
      lack the expected endpoints:
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000030
      ...
      PC is at pl2303_open+0x38/0xec [pl2303]
      
      Note that a missing interrupt-in endpoint would have caused open() to
      fail.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      76ab439e
    • J
      USB: serial: oti6858: fix NULL-deref at open · 5afeef23
      Johan Hovold 提交于
      Fix NULL-pointer dereference in open() should the device lack the
      expected endpoints:
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000030
      ...
      PC is at oti6858_open+0x30/0x1d0 [oti6858]
      
      Note that a missing interrupt-in endpoint would have caused open() to
      fail.
      
      Fixes: 49cdee0e ("USB: oti6858 usb-serial driver (in Nokia CA-42
      cable)")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      5afeef23
    • J
      USB: serial: omninet: fix NULL-derefs at open and disconnect · a5bc0194
      Johan Hovold 提交于
      Fix NULL-pointer dereferences at open() and disconnect() should the
      device lack the expected bulk-out endpoints:
      
      Unable to handle kernel NULL pointer dereference at virtual address 000000b4
      ...
      [c0170ff0>] (__lock_acquire) from [<c0172f00>] (lock_acquire+0x108/0x264)
      [<c0172f00>] (lock_acquire) from [<c06a5090>] (_raw_spin_lock_irqsave+0x58/0x6c)
      [<c06a5090>] (_raw_spin_lock_irqsave) from [<c0470684>] (tty_port_tty_set+0x28/0xa4)
      [<c0470684>] (tty_port_tty_set) from [<bf08d384>] (omninet_open+0x30/0x40 [omninet])
      [<bf08d384>] (omninet_open [omninet]) from [<bf07c118>] (serial_port_activate+0x68/0x98 [usbserial])
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000234
      ...
      [<bf01f418>] (omninet_disconnect [omninet]) from [<bf0016c0>] (usb_serial_disconnect+0xe4/0x100 [usbserial])
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      a5bc0194
    • J
      USB: serial: mos7840: fix misleading interrupt-URB comment · 472d7e55
      Johan Hovold 提交于
      The interrupt URB is killed at final port close since commit
      0de9a702 ("USB: overhaul of mos7840 driver").
      
      Fixes: 0de9a702 ("USB: overhaul of mos7840 driver")
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      472d7e55
    • J
      USB: serial: mos7840: remove unused write URB · fc43e651
      Johan Hovold 提交于
      Remove code to manage a write URB that was never allocated.
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      fc43e651
    • J
      USB: serial: mos7840: fix NULL-deref at open · 5c75633e
      Johan Hovold 提交于
      Fix NULL-pointer dereference in open() should the device lack the
      expected endpoints:
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000030
      ...
      PC is at mos7840_open+0x88/0x8dc [mos7840]
      
      Note that we continue to treat the interrupt-in endpoint as optional for
      now.
      
      Fixes: 3f542974 ("USB: Moschip 7840 USB-Serial Driver")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      5c75633e
    • J
      USB: serial: mos7720: remove obsolete port initialisation · 9da049bc
      Johan Hovold 提交于
      Since commit b69578df ("USB: usbserial: mos7720: add support for
      parallel port on moschip 7715"), the interrupt urb is no longer
      submitted at first port open and the endpoint-address initialisation at
      port-probe is no longer used.
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      9da049bc
    • J
      USB: serial: mos7720: fix parallel probe · fde1faf8
      Johan Hovold 提交于
      A static usb-serial-driver structure that is used to initialise the
      interrupt URB was modified during probe depending on the currently
      probed device type, something which could break a parallel probe of a
      device of a different type.
      
      Fix this up by overriding the default completion callback for MCS7715
      devices in attach() instead. We may want to use two usb-serial driver
      instances for the two types later.
      
      Fixes: fb088e33 ("USB: serial: add support for serial port on the
      moschip 7715")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      fde1faf8
    • J
      USB: serial: mos7720: fix parport use-after-free on probe errors · 75dd211e
      Johan Hovold 提交于
      Do not submit the interrupt URB until after the parport has been
      successfully registered to avoid another use-after-free in the
      completion handler when accessing the freed parport private data in case
      of a racing completion.
      
      Fixes: b69578df ("USB: usbserial: mos7720: add support for parallel
      port on moschip 7715")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      75dd211e
    • J
      USB: serial: mos7720: fix use-after-free on probe errors · 91a1ff4d
      Johan Hovold 提交于
      The interrupt URB was submitted on probe but never stopped on probe
      errors. This can lead to use-after-free issues in the completion
      handler when accessing the freed usb-serial struct:
      
      Unable to handle kernel paging request at virtual address 6b6b6be7
      ...
      [<bf052e70>] (mos7715_interrupt_callback [mos7720]) from [<c052a894>] (__usb_hcd_giveback_urb+0x80/0x140)
      [<c052a894>] (__usb_hcd_giveback_urb) from [<c052a9a4>] (usb_hcd_giveback_urb+0x50/0x138)
      [<c052a9a4>] (usb_hcd_giveback_urb) from [<c0550684>] (musb_giveback+0xc8/0x1cc)
      
      Fixes: b69578df ("USB: usbserial: mos7720: add support for parallel
      port on moschip 7715")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      91a1ff4d
    • J
      USB: serial: mos7720: fix NULL-deref at open · b05aebc2
      Johan Hovold 提交于
      Fix NULL-pointer dereference at port open if a device lacks the expected
      bulk in and out endpoints.
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000030
      ...
      [<bf071c20>] (mos7720_open [mos7720]) from [<bf0490e0>] (serial_port_activate+0x68/0x98 [usbserial])
      [<bf0490e0>] (serial_port_activate [usbserial]) from [<c0470ca4>] (tty_port_open+0x9c/0xe8)
      [<c0470ca4>] (tty_port_open) from [<bf049d98>] (serial_open+0x48/0x6c [usbserial])
      [<bf049d98>] (serial_open [usbserial]) from [<c0469178>] (tty_open+0xcc/0x5cc)
      
      Fixes: 0f64478c ("USB: add USB serial mos7720 driver")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      b05aebc2
    • J
      USB: serial: kobil_sct: fix NULL-deref in write · 21ce5784
      Johan Hovold 提交于
      Fix NULL-pointer dereference in write() should the device lack the
      expected interrupt-out endpoint:
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000054
      ...
      PC is at kobil_write+0x144/0x2a0 [kobil_sct]
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      21ce5784
    • J
      USB: serial: keyspan_pda: verify endpoints at probe · 5d9b0f85
      Johan Hovold 提交于
      Check for the expected endpoints in attach() and fail loudly if not
      present.
      
      Note that failing to do this appears to be benign since da280e34
      ("USB: keyspan_pda: clean up write-urb busy handling") which prevents a
      NULL-pointer dereference in write() by never marking a non-existent
      write-urb as free.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>	# < v3.3
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      5d9b0f85
    • J
      USB: serial: iuu_phoenix: fix NULL-deref at open · 90507d54
      Johan Hovold 提交于
      Fix NULL-pointer dereference at open should the device lack a bulk-in or
      bulk-out endpoint:
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000030
      ...
      PC is at iuu_open+0x78/0x59c [iuu_phoenix]
      
      Fixes: 07c3b1a1 ("USB: remove broken usb-serial num_endpoints
      check")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      90507d54
    • J
      USB: serial: io_ti: bind to interface after fw download · e35d6d7c
      Johan Hovold 提交于
      Bind to the interface, but do not register any ports, after having
      downloaded the firmware. The device will still disconnect and
      re-enumerate, but this way we avoid an error messages from being logged
      as part of the process:
      
      io_ti: probe of 1-1.3:1.0 failed with error -5
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      e35d6d7c
    • J
      USB: serial: io_ti: fix I/O after disconnect · 2330d0a8
      Johan Hovold 提交于
      Cancel the heartbeat work on driver unbind in order to avoid I/O after
      disconnect in case the port is held open.
      
      Note that the cancel in release() is still needed to stop the heartbeat
      after late probe errors.
      
      Fixes: 26c78daa ("USB: io_ti: Add heartbeat to keep idle EP/416
      ports from disconnecting")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      2330d0a8
    • J
      USB: serial: io_ti: fix another NULL-deref at open · 4f9785cc
      Johan Hovold 提交于
      In case a device is left in "boot-mode" we must not register any port
      devices in order to avoid a NULL-pointer dereference on open due to
      missing endpoints. This could be used by a malicious device to trigger
      an OOPS:
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000030
      ...
      [<bf0caa84>] (edge_open [io_ti]) from [<bf0b0118>] (serial_port_activate+0x68/0x98 [usbserial])
      [<bf0b0118>] (serial_port_activate [usbserial]) from [<c0470ca4>] (tty_port_open+0x9c/0xe8)
      [<c0470ca4>] (tty_port_open) from [<bf0b0da0>] (serial_open+0x48/0x6c [usbserial])
      [<bf0b0da0>] (serial_open [usbserial]) from [<c0469178>] (tty_open+0xcc/0x5cc)
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      4f9785cc
    • J
      USB: serial: io_ti: fix NULL-deref at open · a323fefc
      Johan Hovold 提交于
      Fix NULL-pointer dereference when clearing halt at open should a
      malicious device lack the expected endpoints when in download mode.
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000030
      ...
      [<bf011ed8>] (edge_open [io_ti]) from [<bf000118>] (serial_port_activate+0x68/0x98 [usbserial])
      [<bf000118>] (serial_port_activate [usbserial]) from [<c0470ca4>] (tty_port_open+0x9c/0xe8)
      [<c0470ca4>] (tty_port_open) from [<bf000da0>] (serial_open+0x48/0x6c [usbserial])
      [<bf000da0>] (serial_open [usbserial]) from [<c0469178>] (tty_open+0xcc/0x5cc)
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      a323fefc
    • J
      USB: serial: io_edgeport: fix NULL-deref at open · 0dd40842
      Johan Hovold 提交于
      Fix NULL-pointer dereference when initialising URBs at open should a
      non-EPIC device lack a bulk-in or interrupt-in endpoint.
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000028
      ...
      PC is at edge_open+0x24c/0x3e8 [io_edgeport]
      
      Note that the EPIC-device probe path has the required sanity checks so
      this makes those checks partially redundant.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      0dd40842
    • J
      USB: serial: garmin_gps: fix memory leak on failed URB submit · c4ac4496
      Johan Hovold 提交于
      Make sure to free the URB transfer buffer in case submission fails (e.g.
      due to a disconnect).
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      c4ac4496
    • J
      USB: serial: cyberjack: fix NULL-deref at open · 3dca0111
      Johan Hovold 提交于
      Fix NULL-pointer dereference when clearing halt at open should the device
      lack a bulk-out endpoint.
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000030
      ...
      PC is at cyberjack_open+0x40/0x9c [cyberjack]
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      3dca0111
    • F
      usb: host: xhci: handle COMP_STOP from SETUP phase too · 29fc1aa4
      Felipe Balbi 提交于
      Stop Endpoint command can come at any point and we
      have no control of that. We should make sure to
      handle COMP_STOP on SETUP phase as well, otherwise
      urb->actual_length might be set to negative values
      in some occasions such as below:
      
       urb->length = 4;
       build_control_transfer_td_for(urb, ep);
      
       					stop_endpoint(ep);
      
      COMP_STOP:
      	[...]
      	urb->actual_length = urb->length - trb->length;
      
      trb->length is 8 for SETUP stage (8 control request
      bytes), so actual_length would be set to -4 in this
      case.
      
      While doing that, also make sure to use TRB_TYPE
      field of the actual TRB instead of matching pointers
      to figure out in which stage of the control transfer
      we got our completion event.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      29fc1aa4
    • W
      usb: xhci: apply XHCI_PME_STUCK_QUIRK to Intel Apollo Lake · 6c97cfc1
      Wan Ahmad Zainie 提交于
      Intel Apollo Lake also requires XHCI_PME_STUCK_QUIRK.
      Adding its PCI ID to quirk.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NWan Ahmad Zainie <wan.ahmad.zainie.wan.mohamad@intel.com>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6c97cfc1
    • O
      xhci: Fix race related to abort operation · 1c111b6c
      OGAWA Hirofumi 提交于
      Current abort operation has race.
      
          xhci_handle_command_timeout()
            xhci_abort_cmd_ring()
              xhci_write_64(CMD_RING_ABORT)
              xhci_handshake(5s)
      	  do {
      	    check CMD_RING_RUNNING
                  udelay(1)
      					 ...
      					 COMP_CMD_ABORT event
      					 COMP_CMD_STOP event
      					 xhci_handle_stopped_cmd_ring()
      					   restart cmd_ring
                                                 CMD_RING_RUNNING become 1 again
      	  } while ()
                return -ETIMEDOUT
              xhci_write_64(CMD_RING_ABORT)
              /* can abort random command */
      
      To do abort operation correctly, we have to wait both of COMP_CMD_STOP
      event and negation of CMD_RING_RUNNING.
      
      But like above, while timeout handler is waiting negation of
      CMD_RING_RUNNING, event handler can restart cmd_ring. So timeout
      handler never be notice negation of CMD_RING_RUNNING, and retry of
      CMD_RING_ABORT can abort random command (BTW, I guess retry of
      CMD_RING_ABORT was workaround of this race).
      
      To fix this race, this moves xhci_handle_stopped_cmd_ring() to
      xhci_abort_cmd_ring().  And timeout handler waits COMP_CMD_STOP event.
      
      At this point, timeout handler is owner of cmd_ring, and safely
      restart cmd_ring by using xhci_handle_stopped_cmd_ring().
      
      [FWIW, as bonus, this way would be easily extend to add CMD_RING_PAUSE
      operation]
      
      [locks edited as patch is rebased on other locking fixes -Mathias]
      Signed-off-by: NOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1c111b6c
    • O
      xhci: Use delayed_work instead of timer for command timeout · cb4d5ce5
      OGAWA Hirofumi 提交于
      This is preparation to fix abort operation race (See "xhci: Fix race
      related to abort operation"). To make timeout sleepable, use
      delayed_work instead of timer.
      
      [change a newly added pending timer fix to pending work -Mathias]
      Signed-off-by: NOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cb4d5ce5
    • L
      usb: xhci: hold lock over xhci_abort_cmd_ring() · 4dea7077
      Lu Baolu 提交于
      In command timer function, xhci_handle_command_timeout(), xhci->lock
      is unlocked before call into xhci_abort_cmd_ring(). This might cause
      race between the timer function and the event handler.
      
      The xhci_abort_cmd_ring() function sets the CMD_RING_ABORT bit in the
      command register and polling it until the setting takes effect. A stop
      command ring event might be handled between writing the abort bit and
      polling for it. The event handler will restart the command ring, which
      causes the failure of polling, and we ever believed that we failed to
      stop it.
      
      As a bonus, this also fixes some issues of calling functions without
      locking in xhci_handle_command_timeout().
      
      Cc: <stable@vger.kernel.org> # 3.7+
      Signed-off-by: NLu Baolu <baolu.lu@linux.intel.com>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4dea7077
    • M
      xhci: Handle command completion and timeout race · a5a1b951
      Mathias Nyman 提交于
      If we get a command completion event at the same time as the command
      timeout work starts on another cpu we might end up aborting the wrong
      command.
      
      If the command completion takes the xhci lock before the timeout work, it
      will handle the command, pick the next command, mark it as current_cmd, and
      re-queue the timeout work. When the timeout work finally gets the lock
      It will start aborting the wrong command.
      
      This case can be resolved by checking if the timeout work is pending inside
      the timeout function itself. A new timeout work can only be pending if the
      command completed and a new command was queued.
      
      If there are no more commands pending then command completion will set
      the current_cmd to NULL, which is already handled in the timeout work.
      
      Cc: <stable@vger.kernel.org>
      Reported-by: NBaolin Wang <baolin.wang@linaro.org>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a5a1b951
    • B
      usb: host: xhci: Fix possible wild pointer when handling abort command · 2a7cfdf3
      Baolin Wang 提交于
      When current command was supposed to be aborted, host will free the command
      in handle_cmd_completion() function. But it might be still referenced by
      xhci->current_cmd, which need to set NULL.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NBaolin Wang <baolin.wang@linaro.org>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2a7cfdf3
    • L
      usb: xhci: fix possible wild pointer · 2b985467
      Lu Baolu 提交于
      handle_cmd_completion() frees a command structure which might be still
      referenced by xhci->current_cmd.
      This might cause problem when xhci->current_cmd is accessed after that.
      
      A real-life case could be like this. The host takes a very long time to
      respond to a command, and the command timer is fired at the same time
      when the command completion event arrives. The command completion
      handler frees xhci->current_cmd before the timer function can grab
      xhci->lock. Afterward, timer function grabs the lock and go ahead with
      checking and setting members of xhci->current_cmd.
      
      Cc: <stable@vger.kernel.org> # v3.16+
      Signed-off-by: NLu Baolu <baolu.lu@linux.intel.com>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2b985467
    • P
      usb: return error code when platform_get_irq fails · 28bedb5a
      Pan Bian 提交于
      In function xhci_mtk_probe(), variable ret takes the return value. Its
      value should be negative on failures. However, when the call to function
      platform_get_irq() fails, it does not set the error code, and 0 will be
      returned. 0 indicates no error. As a result, the callers of function
      xhci_mtk_probe() will not be able to detect the error. This patch fixes
      the bug by assigning the return value of platform_get_irq() to variable
      ret if it fails.
      
      CC: <stable@vger.kernel.org>
      Signed-off-by: NPan Bian <bianpan2016@163.com>
      Reviewed-by: NMatthias Brugger <matthias.bgg@gmail.com>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      28bedb5a
    • L
      usb: xhci: fix return value of xhci_setup_device() · 90797aee
      Lu Baolu 提交于
      xhci_setup_device() should return failure with correct error number
      when xhci host has died, removed or halted.
      
      During usb device enumeration, if usb host is not accessible (died,
      removed or halted), the hc_driver->address_device() should return
      a corresponding error code to usb core. But current xhci driver just
      returns success. This misleads usb core to continue the enumeration
      by reading the device descriptor, which will result in failure, and
      users will get a misleading message like "device descriptor read/8,
      error -110".
      
      Cc: <stable@vger.kernel.org> # v4.3+
      Signed-off-by: NLu Baolu <baolu.lu@linux.intel.com>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      90797aee
    • M
      xhci: free xhci virtual devices with leaf nodes first · ee8665e2
      Mathias Nyman 提交于
      the tt_info provided by a HS hub might be in use to by a child device
      Make sure we free the devices in the correct order.
      
      This is needed in special cases such as when xhci controller is
      reset when resuming from hibernate, and all virt_devices are freed.
      
      Also free the virt_devices starting from max slot_id as children
      more commonly have higher slot_id than parent.
      
      CC: <stable@vger.kernel.org>
      Reported-by: NGuenter Roeck <groeck@chromium.org>
      Tested-by: NGuenter Roeck <groeck@chromium.org>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ee8665e2
  3. 03 1月, 2017 2 次提交