1. 17 Jul, 2014 40 commits
    • Peter Chen's avatar
      usb: chipidea: udc: delete td from req's td list at ep_dequeue · 6b94ad95
      Peter Chen authored
      commit e4adcff0 upstream.
      
      We need to delete un-finished td from current request's td list
      at ep_dequeue API, otherwise, this non-user td will be remained
      at td list before this request is freed. So if we do ep_queue->
      ep_dequeue->ep_queue sequence, when the complete interrupt for
      the second ep_queue comes, we search td list for this request,
      the first td (added by the first ep_queue) will be handled, and
      its status is still active, so we will consider the this transfer
      still not be completed, but in fact, it has completed. It causes
      the peripheral side considers it never receives current data for
      this transfer.
      
      We met this problem when do "Error Recovery Test - Device Configured"
      test item for USBCV2 MSC test, the host has never received ACK for
      the IN token for CSW due to peripheral considers it does not get this
      CBW, the USBCV test log like belows:
      
      --------------------------------------------------------------------------
      INFO
      Issuing BOT MSC Reset, reset should always succeed
      INFO
      Retrieving status on CBW endpoint
      INFO
      CBW endpoint status = 0x0
      INFO
      Retrieving status on CSW endpoint
      INFO
      CSW endpoint status = 0x0
      INFO
      Issuing required command (Test Unit Ready) to verify device has recovered
      INFO
      Issuing CBW (attempt #1):
      INFO
      |----- CBW LUN                  = 0x0
      INFO
      |----- CBW Flags                = 0x0
      INFO
      |----- CBW Data Transfer Length = 0x0
      INFO
      |----- CBW CDB Length           = 0x6
      INFO
      |----- CBW CDB-00 = 0x0
      INFO
      |----- CBW CDB-01 = 0x0
      INFO
      |----- CBW CDB-02 = 0x0
      INFO
      |----- CBW CDB-03 = 0x0
      INFO
      |----- CBW CDB-04 = 0x0
      INFO
      |----- CBW CDB-05 = 0x0
      INFO
      Issuing CSW : try 1
      INFO
      CSW Bulk Request timed out!
      ERROR
      Failed CSW phase : should have been success or stall
      FAIL
      (5.3.4) The CSW status value must be 0x00, 0x01, or 0x02.
      ERROR
      BOTCommonMSCRequest failed:  error=80004000
      
      Cc: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
      Signed-off-by: default avatarPeter Chen <peter.chen@freescale.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      6b94ad95
    • Ezequiel Garcia's avatar
      usb: musb: Fix panic upon musb_am335x module removal · a92e6f70
      Ezequiel Garcia authored
      commit 7adb5c87 upstream.
      
      At probe time, the musb_am335x driver register its childs by
      calling of_platform_populate(), which registers all childs in
      the devicetree hierarchy recursively.
      
      On the other side, the driver's remove() function uses of_device_unregister()
      to remove each child of musb_am335x's.
      
      However, when musb_dsps is loaded, its devices are attached to the musb_am335x
      device as musb_am335x childs. Hence, musb_am335x remove() will attempt to
      unregister the devices registered by musb_dsps, which produces a kernel panic.
      
      In other words, the childs in the "struct device" hierarchy are not the same
      as the childs in the "devicetree" hierarchy.
      
      Ideally, we should enforce the removal of the devices registered by
      musb_am335x *only*, instead of all its child devices. However, because of the
      recursive nature of of_platform_populate, this doesn't seem possible.
      
      Therefore, as the only solution at hand, this commit disables musb_am335x
      driver removal capability, preventing it from being ever removed. This was
      originally suggested by Sebastian Siewior:
      
      https://www.mail-archive.com/linux-omap@vger.kernel.org/msg104946.html
      
      And for reference, here's the panic upon module removal:
      
      musb-hdrc musb-hdrc.0.auto: remove, state 4
      usb usb1: USB disconnect, device number 1
      musb-hdrc musb-hdrc.0.auto: USB bus 1 deregistered
      Unable to handle kernel NULL pointer dereference at virtual address 0000008c
      pgd = de11c000
      [0000008c] *pgd=9e174831, *pte=00000000, *ppte=00000000
      Internal error: Oops: 17 [#1] ARM
      Modules linked in: musb_am335x(-) musb_dsps musb_hdrc usbcore usb_common
      CPU: 0 PID: 623 Comm: modprobe Not tainted 3.15.0-rc4-00001-g24efd13 #69
      task: de1b7500 ti: de122000 task.ti: de122000
      PC is at am335x_shutdown+0x10/0x28
      LR is at am335x_shutdown+0xc/0x28
      pc : [<c0327798>]    lr : [<c0327794>]    psr: a0000013
      sp : de123df8  ip : 00000004  fp : 00028f00
      r10: 00000000  r9 : de122000  r8 : c000e6c4
      r7 : de0e3c10  r6 : de0e3800  r5 : de624010  r4 : de1ec750
      r3 : de0e3810  r2 : 00000000  r1 : 00000001  r0 : 00000000
      Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
      Control: 10c5387d  Table: 9e11c019  DAC: 00000015
      Process modprobe (pid: 623, stack limit = 0xde122240)
      Stack: (0xde123df8 to 0xde124000)
      3de0:                                                       de0e3810 bf054488
      3e00: bf05444c de624010 60000013 bf043650 000012fc de624010 de0e3810 bf043a20
      3e20: de0e3810 bf04b240 c0635b88 c02ca37c c02ca364 c02c8db0 de1b7500 de0e3844
      3e40: de0e3810 c02c8e28 c0635b88 de02824c de0e3810 c02c884c de0e3800 de0e3810
      3e60: de0e3818 c02c5b20 bf05417c de0e3800 de0e3800 c0635b88 de0f2410 c02ca838
      3e80: bf05417c de0e3800 bf055438 c02ca8cc de0e3c10 bf054194 de0e3c10 c02ca37c
      3ea0: c02ca364 c02c8db0 de1b7500 de0e3c44 de0e3c10 c02c8e28 c0635b88 de02824c
      3ec0: de0e3c10 c02c884c de0e3c10 de0e3c10 de0e3c18 c02c5b20 de0e3c10 de0e3c10
      3ee0: 00000000 bf059000 a0000013 c02c5bc0 00000000 bf05900c de0e3c10 c02c5c48
      3f00: de0dd0c0 de1ec970 de0f2410 bf05929c de0f2444 bf05902c de0f2410 c02ca37c
      3f20: c02ca364 c02c8db0 bf05929c de0f2410 bf05929c c02c94c8 bf05929c 00000000
      3f40: 00000800 c02c8ab4 bf0592e0 c007fc40 c00dd820 6273756d 336d615f 00783533
      3f60: c064a0ac de1b7500 de122000 de1b7500 c000e590 00000001 c000e6c4 c0060160
      3f80: 00028e70 00028e70 00028ea4 00000081 60000010 00028e70 00028e70 00028ea4
      3fa0: 00000081 c000e500 00028e70 00028e70 00028ea4 00000800 becb59f8 00027608
      3fc0: 00028e70 00028e70 00028ea4 00000081 00000001 00000001 00000000 00028f00
      3fe0: b6e6b6f0 becb59d4 000160e8 b6e6b6fc 60000010 00028ea4 00000000 00000000
      [<c0327798>] (am335x_shutdown) from [<bf054488>] (dsps_musb_exit+0x3c/0x4c [musb_dsps])
      [<bf054488>] (dsps_musb_exit [musb_dsps]) from [<bf043650>] (musb_shutdown+0x80/0x90 [musb_hdrc])
      [<bf043650>] (musb_shutdown [musb_hdrc]) from [<bf043a20>] (musb_remove+0x24/0x68 [musb_hdrc])
      [<bf043a20>] (musb_remove [musb_hdrc]) from [<c02ca37c>] (platform_drv_remove+0x18/0x1c)
      [<c02ca37c>] (platform_drv_remove) from [<c02c8db0>] (__device_release_driver+0x70/0xc8)
      [<c02c8db0>] (__device_release_driver) from [<c02c8e28>] (device_release_driver+0x20/0x2c)
      [<c02c8e28>] (device_release_driver) from [<c02c884c>] (bus_remove_device+0xdc/0x10c)
      [<c02c884c>] (bus_remove_device) from [<c02c5b20>] (device_del+0x104/0x198)
      [<c02c5b20>] (device_del) from [<c02ca838>] (platform_device_del+0x14/0x9c)
      [<c02ca838>] (platform_device_del) from [<c02ca8cc>] (platform_device_unregister+0xc/0x20)
      [<c02ca8cc>] (platform_device_unregister) from [<bf054194>] (dsps_remove+0x18/0x38 [musb_dsps])
      [<bf054194>] (dsps_remove [musb_dsps]) from [<c02ca37c>] (platform_drv_remove+0x18/0x1c)
      [<c02ca37c>] (platform_drv_remove) from [<c02c8db0>] (__device_release_driver+0x70/0xc8)
      [<c02c8db0>] (__device_release_driver) from [<c02c8e28>] (device_release_driver+0x20/0x2c)
      [<c02c8e28>] (device_release_driver) from [<c02c884c>] (bus_remove_device+0xdc/0x10c)
      [<c02c884c>] (bus_remove_device) from [<c02c5b20>] (device_del+0x104/0x198)
      [<c02c5b20>] (device_del) from [<c02c5bc0>] (device_unregister+0xc/0x20)
      [<c02c5bc0>] (device_unregister) from [<bf05900c>] (of_remove_populated_child+0xc/0x14 [musb_am335x])
      [<bf05900c>] (of_remove_populated_child [musb_am335x]) from [<c02c5c48>] (device_for_each_child+0x44/0x70)
      [<c02c5c48>] (device_for_each_child) from [<bf05902c>] (am335x_child_remove+0x18/0x30 [musb_am335x])
      [<bf05902c>] (am335x_child_remove [musb_am335x]) from [<c02ca37c>] (platform_drv_remove+0x18/0x1c)
      [<c02ca37c>] (platform_drv_remove) from [<c02c8db0>] (__device_release_driver+0x70/0xc8)
      [<c02c8db0>] (__device_release_driver) from [<c02c94c8>] (driver_detach+0xb4/0xb8)
      [<c02c94c8>] (driver_detach) from [<c02c8ab4>] (bus_remove_driver+0x4c/0xa0)
      [<c02c8ab4>] (bus_remove_driver) from [<c007fc40>] (SyS_delete_module+0x128/0x1cc)
      [<c007fc40>] (SyS_delete_module) from [<c000e500>] (ret_fast_syscall+0x0/0x48)
      
      Fixes: 97238b35 ("usb: musb: dsps: use proper child nodes")
      Acked-by: default avatarGeorge Cherian <george.cherian@ti.com>
      Signed-off-by: default avatarEzequiel Garcia <ezequiel@vanguardiasur.com.ar>
      Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      a92e6f70
    • Thomas Gleixner's avatar
      usb: musb: Ensure that cppi41 timer gets armed on premature DMA TX irq · cfc3a680
      Thomas Gleixner authored
      commit c58d80f5 upstream.
      
      Some TI chips raise the DMA complete interrupt before the actual
      transfer has been completed. The code tries to busy wait for a few
      microseconds and if that fails it arms an hrtimer to recheck. So far
      so good, but that has the following issue:
      
      CPU 0					CPU1
      
      start_next_transfer(RQ1);
      
      DMA interrupt
        if (premature_irq(RQ1))
          if (!hrtimer_active(timer))
             hrtimer_start(timer);
      
      hrtimer expires
        timer->state = CALLBACK_RUNNING;
        timer->fn()
          cppi41_recheck_tx_req()
            complete_request(RQ1);
            if (requests_pending())
              start_next_transfer(RQ2);
      
      					DMA interrupt
      					  if (premature_irq(RQ2))
      					    if (!hrtimer_active(timer))
      					       hrtimer_start(timer);
        timer->state = INACTIVE;
      
      The premature interrupt of request2 on CPU1 does not arm the timer and
      therefor the request completion never happens because it checks for
      !hrtimer_active(). hrtimer_active() evaluates:
      
        timer->state != HRTIMER_STATE_INACTIVE
      
      which of course evaluates to true in the above case as timer->state is
      CALLBACK_RUNNING.
      
      That's clearly documented:
      
       * A timer is active, when it is enqueued into the rbtree or the
       * callback function is running or it's in the state of being migrated
       * to another cpu.
      
      But that's not what the code wants to check. The code wants to check
      whether the timer is queued, i.e. whether its armed and waiting for
      expiry.
      
      We have a helper function for this: hrtimer_is_queued(). This
      evaluates:
      
        timer->state & HRTIMER_STATE_QUEUED
      
      So in the above case this evaluates to false and therefor forces the
      DMA interrupt on CPU1 to call hrtimer_start().
      
      Use hrtimer_is_queued() instead of hrtimer_active() and evrything is
      good.
      Reported-by: default avatarTorben Hohn <torbenh@linutronix.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      cfc3a680
    • Linus Walleij's avatar
      usb: musb: ux500: don't propagate the OF node · 52b2230b
      Linus Walleij authored
      commit 82363cf2 upstream.
      
      There is a regression in the upcoming v3.16-rc1, that is caused
      by a problem that has been around for a while but now finally
      hangs the system. The bootcrawl looks like this:
      
      pinctrl-nomadik soc:pinctrl: pin GPIO256_AF28 already
      requested by a03e0000.usb_per5; cannot claim for musb-hdrc.0.auto
      pinctrl-nomadik soc:pinctrl: pin-256 (musb-hdrc.0.auto) status -22
      pinctrl-nomadik soc:pinctrl: could not request pin 256
      (GPIO256_AF28) from group usb_a_1  on device pinctrl-nomadik
      musb-hdrc musb-hdrc.0.auto: Error applying setting, reverse
      things back
      HS USB OTG: no transceiver configured
      musb-hdrc musb-hdrc.0.auto: musb_init_controller failed
      with status -517
      platform musb-hdrc.0.auto: Driver musb-hdrc requests
      probe deferral
      (...)
      
      The ux500 MUSB driver propagates the OF node to the dynamically
      created musb-hdrc device, which is incorrect as it makes the OF
      core believe there are two devices spun from the very same
      DT node, which confuses other parts of the device core, notably
      the pin control subsystem, which will try to apply all the pin
      control settings also to the HDRC device as it gets
      instantiated. (The OMAP2430 for example, does not set the
      of_node member.)
      
      Cc: Arnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      52b2230b
    • Bjørn Mork's avatar
      usb: option: add/modify Olivetti Olicard modems · 8a83c856
      Bjørn Mork authored
      commit b0ebef36 upstream.
      
      Adding a couple of Olivetti modems and blacklisting the net
      function on a couple which are already supported.
      Reported-by: default avatarLars Melin <larsm17@gmail.com>
      Signed-off-by: default avatarBjørn Mork <bjorn@mork.no>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      8a83c856
    • Oliver Neukum's avatar
      USB: option: add device ID for SpeedUp SU9800 usb 3g modem · 245fbe91
      Oliver Neukum authored
      commit 1cab4c68 upstream.
      
      Reported by Alif Mubarak Ahmad:
      
      This device vendor and product id is 1c9e:9800
      It is working as serial interface with generic usbserial driver.
      I thought it is more suitable to use usbserial option driver, which has
      better capability distinguishing between modem serial interface and
      micro sd storage interface.
      
      [ johan: style changes ]
      Signed-off-by: default avatarOliver Neukum <oneukum@suse.de>
      Tested-by: default avatarAlif Mubarak Ahmad <alive4ever@live.com>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      245fbe91
    • Wang, Yu's avatar
      xhci: Fix runtime suspended xhci from blocking system suspend. · f9b96e0f
      Wang, Yu authored
      commit d6236f6d upstream.
      
      The system suspend flow as following:
      1, Freeze all user processes and kenrel threads.
      
      2, Try to suspend all devices.
      
      2.1, If pci device is in RPM suspended state, then pci driver will try
      to resume it to RPM active state in the prepare stage.
      
      2.2, xhci_resume function calls usb_hcd_resume_root_hub to queue two
      workqueue items to resume usb2&usb3 roothub devices.
      
      2.3, Call suspend callbacks of devices.
      
      2.3.1, All suspend callbacks of all hcd's children, including
      roothub devices are called.
      
      2.3.2, Finally, hcd_pci_suspend callback is called.
      
      Due to workqueue threads were already frozen in step 1, the workqueue
      items can't be scheduled, and the roothub devices can't be resumed in
      this flow. The HCD_FLAG_WAKEUP_PENDING flag which is set in
      usb_hcd_resume_root_hub won't be cleared. Finally,
      hcd_pci_suspend will return -EBUSY, and system suspend fails.
      
      The reason why this issue doesn't show up very often is due to that
      choose_wakeup will be called in step 2.3.1. In step 2.3.1, if
      udev->do_remote_wakeup is not equal to device_may_wakeup(&udev->dev), then
      udev will resume to RPM active for changing the wakeup settings. This
      has been a lucky hit which hides this issue.
      
      For some special xHCI controllers which have no USB2 port, then roothub
      will not match hub driver due to probe failed. Then its
      do_remote_wakeup will be set to zero, and we won't be as lucky.
      
      xhci driver doesn't need to resume roothub devices everytime like in
      the above case. It's only needed when there are pending event TRBs.
      
      This patch should be back-ported to kernels as old as 3.2, that
      contains the commit f69e3120
      "USB: XHCI: resume root hubs when the controller resumes"
      Signed-off-by: default avatarWang, Yu <yu.y.wang@intel.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      [use readl() instead of removed xhci_readl(), reword commit message -Mathias]
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      f9b96e0f
    • Mathias Nyman's avatar
      xhci: correct burst count field for isoc transfers on 1.0 xhci hosts · 02fe4134
      Mathias Nyman authored
      commit 3213b151 upstream.
      
      The transfer burst count (TBC) field in xhci 1.0 hosts should be set
      to the number of bursts needed to transfer all packets in a isoc TD.
      Supported values are 0-2 (1 to 3 bursts per service interval).
      
      Formula for TBC calculation is given in xhci spec section 4.11.2.3:
      TBC = roundup( Transfer Descriptor Packet Count / Max Burst Size +1 ) - 1
      
      This patch should be applied to stable kernels since 3.0 that contain
      the commit 5cd43e33
      "xhci 1.0: Set transfer burst count field."
      Suggested-by: default avatarShiChun Ma <masc2008@qq.com>
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      02fe4134
    • Paolo Bonzini's avatar
      virtio-scsi: fix various bad behavior on aborted requests · e377f153
      Paolo Bonzini authored
      commit 8faeb529 upstream.
      
      Even though the virtio-scsi spec guarantees that all requests related
      to the TMF will have been completed by the time the TMF itself completes,
      the request queue's callback might not have run yet.  This causes requests
      to be completed more than once, and as a result triggers a variety of
      BUGs or oopses.
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: default avatarVenkatesh Srinivas <venkateshs@google.com>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      e377f153
    • Ulrich Obergfell's avatar
      scsi_error: fix invalid setting of host byte · ddefcdd6
      Ulrich Obergfell authored
      commit 8922a908 upstream.
      
      After scsi_try_to_abort_cmd returns, the eh_abort_handler may have
      already found that the command has completed in the device, causing
      the host_byte to be nonzero (e.g. it could be DID_ABORT).  When
      this happens, ORing DID_TIME_OUT into the host byte will corrupt
      the result field and initiate an unwanted command retry.
      
      Fix this by using set_host_byte instead, following the model of
      commit 2082ebc4.
      Signed-off-by: default avatarUlrich Obergfell <uobergfe@redhat.com>
      [Fix all instances according to review comments. - Paolo]
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarEwan D. Milne <emilne@redhat.com>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      ddefcdd6
    • Paolo Bonzini's avatar
      virtio-scsi: avoid cancelling uninitialized work items · 424d0d5d
      Paolo Bonzini authored
      commit cdda0e5a upstream.
      
      Calling the workqueue interface on uninitialized work items isn't a
      good idea even if they're zeroed. It's not failing catastrophically only
      through happy accidents.
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      424d0d5d
    • Brian King's avatar
      ibmvscsi: Add memory barriers for send / receive · 4cd3c8a2
      Brian King authored
      commit 7114aae0 upstream.
      
      Add a memory barrier prior to sending a new command to the VIOS
      to ensure the VIOS does not receive stale data in the command buffer.
      Also add a memory barrier when processing the CRQ for completed commands.
      Signed-off-by: default avatarBrian King <brking@linux.vnet.ibm.com>
      Acked-by: default avatarNathan Fontenot <nfont@linux.vnet.ibm.com>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      4cd3c8a2
    • Brian King's avatar
      ibmvscsi: Abort init sequence during error recovery · a9b8dab6
      Brian King authored
      commit 9ee75597 upstream.
      
      If a CRQ reset is triggered for some reason while in the middle
      of performing VSCSI adapter initialization, we don't want to
      call the done function for the initialization MAD commands as
      this will only result in two threads attempting initialization
      at the same time, resulting in failures.
      Signed-off-by: default avatarBrian King <brking@linux.vnet.ibm.com>
      Acked-by: default avatarNathan Fontenot <nfont@linux.vnet.ibm.com>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      a9b8dab6
    • Takashi Iwai's avatar
      ALSA: usb-audio: Fix races at disconnection and PCM closing · 9d1274d1
      Takashi Iwai authored
      commit 92a586bd upstream.
      
      When a USB-audio device is disconnected while PCM is still running, we
      still see some race: the disconnect callback calls
      snd_usb_endpoint_free() that calls release_urbs() and then kfree()
      while a PCM stream would be closed at the same time and calls
      stop_endpoints() that leads to wait_clear_urbs().  That is, the EP
      object might be deallocated while a PCM stream is syncing with
      wait_clear_urbs() with the same EP.
      
      Basically calling multiple wait_clear_urbs() would work fine, also
      calling wait_clear_urbs() and release_urbs() would work, too, as
      wait_clear_urbs() just reads some fields in ep.  The problem is the
      succeeding kfree() in snd_pcm_endpoint_free().
      
      This patch moves out the EP deallocation into the later point, the
      destructor callback.  At this stage, all PCMs must have been already
      closed, so it's safe to free the objects.
      Reported-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      9d1274d1
    • Oleg Nesterov's avatar
      tracing: Fix syscall_*regfunc() vs copy_process() race · 1855b4bd
      Oleg Nesterov authored
      commit 4af4206b upstream.
      
      syscall_regfunc() and syscall_unregfunc() should set/clear
      TIF_SYSCALL_TRACEPOINT system-wide, but do_each_thread() can race
      with copy_process() and miss the new child which was not added to
      the process/thread lists yet.
      
      Change copy_process() to update the child's TIF_SYSCALL_TRACEPOINT
      under tasklist.
      
      Link: http://lkml.kernel.org/p/20140413185854.GB20668@redhat.com
      
      Fixes: a871bd33 "tracing: Add syscall tracepoints"
      Acked-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Acked-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      1855b4bd
    • Steven Rostedt (Red Hat)'s avatar
      tracing: Try again for saved cmdline if failed due to locking · 0ecae6cb
      Steven Rostedt (Red Hat) authored
      commit 379cfdac upstream.
      
      In order to prevent the saved cmdline cache from being filled when
      tracing is not active, the comms are only recorded after a trace event
      is recorded.
      
      The problem is, a comm can fail to be recorded if the trace_cmdline_lock
      is held. That lock is taken via a trylock to allow it to happen from
      any context (including NMI). If the lock fails to be taken, the comm
      is skipped. No big deal, as we will try again later.
      
      But! Because of the code that was added to only record after an event,
      we may not try again later as the recording is made as a oneshot per
      event per CPU.
      
      Only disable the recording of the comm if the comm is actually recorded.
      
      Fixes: 7ffbd48d "tracing: Cache comms only after an event occurred"
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      0ecae6cb
    • Jacob Keller's avatar
      Documentation/SubmittingPatches: describe the Fixes: tag · 0b052a0d
      Jacob Keller authored
      commit 8401aa1f upstream.
      
      Update the SubmittingPatches process to include howto about the new
      'Fixes:' tag to be used when a patch fixes an issue in a previous commit
      (found by git-bisect for example).
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      0b052a0d
    • Greg Kroah-Hartman's avatar
      lz4: add overrun checks to lz4_uncompress_unknownoutputsize() · fac842fd
      Greg Kroah-Hartman authored
      commit 4a3a9904 upstream.
      
      Jan points out that I forgot to make the needed fixes to the
      lz4_uncompress_unknownoutputsize() function to mirror the changes done
      in lz4_decompress() with regards to potential pointer overflows.
      
      The only in-kernel user of this function is the zram code, which only
      takes data from a valid compressed buffer that it made itself, so it's
      not a big issue.  But due to external kernel modules using this
      function, it's better to be safe here.
      Reported-by: default avatarJan Beulich <JBeulich@suse.com>
      Cc: "Don A. Bailey" <donb@securitymouse.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      fac842fd
    • Tejun Heo's avatar
      ptrace,x86: force IRET path after a ptrace_stop() · 2f182440
      Tejun Heo authored
      commit b9cd18de upstream.
      
      The 'sysret' fastpath does not correctly restore even all regular
      registers, much less any segment registers or reflags values.  That is
      very much part of why it's faster than 'iret'.
      
      Normally that isn't a problem, because the normal ptrace() interface
      catches the process using the signal handler infrastructure, which
      always returns with an iret.
      
      However, some paths can get caught using ptrace_event() instead of the
      signal path, and for those we need to make sure that we aren't going to
      return to user space using 'sysret'.  Otherwise the modifications that
      may have been done to the register set by the tracer wouldn't
      necessarily take effect.
      
      Fix it by forcing IRET path by setting TIF_NOTIFY_RESUME from
      arch_ptrace_stop_needed() which is invoked from ptrace_stop().
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reported-by: default avatarAndy Lutomirski <luto@amacapital.net>
      Acked-by: default avatarOleg Nesterov <oleg@redhat.com>
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      2f182440
    • Peter Christensen's avatar
      ipvs: Fix panic due to non-linear skb · 8391d35e
      Peter Christensen authored
      commit f44a5f45 upstream.
      
      Receiving a ICMP response to an IPIP packet in a non-linear skb could
      cause a kernel panic in __skb_pull.
      
      The problem was introduced in
      commit f2edb9f7 ("ipvs: implement
      passive PMTUD for IPIP packets").
      Signed-off-by: default avatarPeter Christensen <pch@ordbogen.com>
      Acked-by: default avatarJulian Anastasov <ja@ssi.bg>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      8391d35e
    • Deng-Cheng Zhu's avatar
      MIPS: KVM: Fix memory leak on VCPU · e7f46b90
      Deng-Cheng Zhu authored
      commit 8c9eb041 upstream.
      
      kvm_arch_vcpu_free() is called in 2 code paths:
      
      1) kvm_vm_ioctl()
             kvm_vm_ioctl_create_vcpu()
                 kvm_arch_vcpu_destroy()
                     kvm_arch_vcpu_free()
      2) kvm_put_kvm()
             kvm_destroy_vm()
                 kvm_arch_destroy_vm()
                     kvm_mips_free_vcpus()
                         kvm_arch_vcpu_free()
      
      Neither of the paths handles VCPU free. We need to do it in
      kvm_arch_vcpu_free() corresponding to the memory allocation in
      kvm_arch_vcpu_create().
      Signed-off-by: default avatarDeng-Cheng Zhu <dengcheng.zhu@imgtec.com>
      Reviewed-by: default avatarJames Hogan <james.hogan@imgtec.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      e7f46b90
    • James Hogan's avatar
      MIPS: KVM: Remove redundant NULL checks before kfree() · 13fa8def
      James Hogan authored
      commit c6c0a663 upstream.
      
      The kfree() function already NULL checks the parameter so remove the
      redundant NULL checks before kfree() calls in arch/mips/kvm/.
      Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Gleb Natapov <gleb@kernel.org>
      Cc: kvm@vger.kernel.org
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: Sanjay Lal <sanjayl@kymasys.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      13fa8def
    • Jeff Mahoney's avatar
      reiserfs: call truncate_setsize under tailpack mutex · a4424b76
      Jeff Mahoney authored
      commit 22e7478d upstream.
      
      Prior to commit 0e4f6a79 (Fix reiserfs_file_release()), reiserfs
      truncates serialized on i_mutex. They mostly still do, with the exception
      of reiserfs_file_release. That blocks out other writers via the tailpack
      mutex and the inode openers counter adjusted in reiserfs_file_open.
      
      However, NFS will call reiserfs_setattr without having called ->open, so
      we end up with a race when nfs is calling ->setattr while another
      process is releasing the file. Ultimately, it triggers the
      BUG_ON(inode->i_size != new_file_size) check in maybe_indirect_to_direct.
      
      The solution is to pull the lock into reiserfs_setattr to encompass the
      truncate_setsize call as well.
      Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      a4424b76
    • Scott Wood's avatar
      powerpc: Don't skip ePAPR spin-table CPUs · 24cba162
      Scott Wood authored
      commit 6663a4fa upstream.
      
      Commit 59a53afe "powerpc: Don't setup
      CPUs with bad status" broke ePAPR SMP booting.  ePAPR says that CPUs
      that aren't presently running shall have status of disabled, with
      enable-method being used to determine whether the CPU can be enabled.
      
      Fix by checking for spin-table, which is currently the only supported
      enable-method.
      Signed-off-by: default avatarScott Wood <scottwood@freescale.com>
      Cc: Michael Neuling <mikey@neuling.org>
      Cc: Emil Medve <Emilian.Medve@Freescale.com>
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      24cba162
    • Benjamin Herrenschmidt's avatar
      powerpc: Add AT_HWCAP2 to indicate V.CRYPTO category support · 9994e2c2
      Benjamin Herrenschmidt authored
      commit dd58a092 upstream.
      
      The Vector Crypto category instructions are supported by current POWER8
      chips, advertise them to userspace using a specific bit to properly
      differentiate with chips of the same architecture level that might not
      have them.
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      9994e2c2
    • Michael Neuling's avatar
      powerpc: Don't setup CPUs with bad status · c5aee1fa
      Michael Neuling authored
      commit 59a53afe upstream.
      
      OPAL will mark a CPU that is guarded as "bad" in the status property of the CPU
      node.
      
      Unfortunatley Linux doesn't check this property and will put the bad CPU in the
      present map.  This has caused hangs on booting when we try to unsplit the core.
      
      This patch checks the CPU is avaliable via this status property before putting
      it in the present map.
      Signed-off-by: default avatarMichael Neuling <mikey@neuling.org>
      Tested-by: default avatarAnton Blanchard <anton@samba.org>
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      c5aee1fa
    • Paul Bolle's avatar
      powerpc: fix typo 'CONFIG_PPC_CPU' · 2d16f738
      Paul Bolle authored
      commit b69a1da9 upstream.
      
      Commit cd64d169 ("powerpc: mtmsrd not defined") added a check for
      CONFIG_PPC_CPU were a check for CONFIG_PPC_FPU was clearly intended.
      
      Fixes: cd64d169 ("powerpc: mtmsrd not defined")
      Signed-off-by: default avatarPaul Bolle <pebolle@tiscali.nl>
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      2d16f738
    • Michael Ellerman's avatar
      powerpc/perf: Ensure all EBB register state is cleared on fork() · 58da9b25
      Michael Ellerman authored
      commit 3df48c98 upstream.
      
      In commit 330a1eb7 "Core EBB support for 64-bit book3s" I messed up
      clear_task_ebb(). It clears some but not all of the task's Event Based
      Branch (EBB) registers when we duplicate a task struct.
      
      That allows a child task to observe the EBBHR & EBBRR of its parent,
      which it should not be able to do.
      
      Fix it by clearing EBBHR & EBBRR.
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      58da9b25
    • Paul Bolle's avatar
      powerpc: fix typo 'CONFIG_PMAC' · 10645ebc
      Paul Bolle authored
      commit 6e0fdf9a upstream.
      
      Commit b0d278b7 ("powerpc/perf_event: Reduce latency of calling
      perf_event_do_pending") added a check for CONFIG_PMAC were a check for
      CONFIG_PPC_PMAC was clearly intended.
      
      Fixes: b0d278b7 ("powerpc/perf_event: Reduce latency of calling perf_event_do_pending")
      Signed-off-by: default avatarPaul Bolle <pebolle@tiscali.nl>
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      10645ebc
    • Anton Blanchard's avatar
      powerpc: 64bit sendfile is capped at 2GB · c3043360
      Anton Blanchard authored
      commit 5d73320a upstream.
      
      commit 8f9c0119 (compat: fs: Generic compat_sys_sendfile
      implementation) changed the PowerPC 64bit sendfile call from
      sys_sendile64 to sys_sendfile.
      
      Unfortunately this broke sendfile of lengths greater than 2G because
      sys_sendfile caps at MAX_NON_LFS. Restore what we had previously which
      fixes the bug.
      Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      c3043360
    • Benjamin Herrenschmidt's avatar
      powerpc/serial: Use saner flags when creating legacy ports · 0c35d0ca
      Benjamin Herrenschmidt authored
      commit c4cad90f upstream.
      
      We had a mix & match of flags used when creating legacy ports
      depending on where we found them in the device-tree. Among others
      we were missing UPF_SKIP_TEST for some kind of ISA ports which is
      a problem as quite a few UARTs out there don't support the loopback
      test (such as a lot of BMCs).
      
      Let's pick the set of flags used by the SoC code and generalize it
      which means autoconf, no loopback test, irq maybe shared and fixed
      port.
      
      Sending to stable as the lack of UPF_SKIP_TEST is breaking
      serial on some machines so I want this back into distros
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      0c35d0ca
    • Michael Ellerman's avatar
      powerpc/mm: Check paca psize is up to date for huge mappings · 0ddc881b
      Michael Ellerman authored
      commit 09567e7f upstream.
      
      We have a bug in our hugepage handling which exhibits as an infinite
      loop of hash faults. If the fault is being taken in the kernel it will
      typically trigger the softlockup detector, or the RCU stall detector.
      
      The bug is as follows:
      
       1. mmap(0xa0000000, ..., MAP_FIXED | MAP_HUGE_TLB | MAP_ANONYMOUS ..)
       2. Slice code converts the slice psize to 16M.
       3. The code on lines 539-540 of slice.c in slice_get_unmapped_area()
          synchronises the mm->context with the paca->context. So the paca slice
          mask is updated to include the 16M slice.
       3. Either:
          * mmap() fails because there are no huge pages available.
          * mmap() succeeds and the mapping is then munmapped.
          In both cases the slice psize remains at 16M in both the paca & mm.
       4. mmap(0xa0000000, ..., MAP_FIXED | MAP_ANONYMOUS ..)
       5. The slice psize is converted back to 64K. Because of the check on line 539
          of slice.c we DO NOT update the paca->context. The paca slice mask is now
          out of sync with the mm slice mask.
       6. User/kernel accesses 0xa0000000.
       7. The SLB miss handler slb_allocate_realmode() **uses the paca slice mask**
          to create an SLB entry and inserts it in the SLB.
      18. With the 16M SLB entry in place the hardware does a hash lookup, no entry
          is found so a data access exception is generated.
      19. The data access handler calls do_page_fault() -> handle_mm_fault().
      10. __handle_mm_fault() creates a THP mapping with do_huge_pmd_anonymous_page().
      11. The hardware retries the access, there is still nothing in the hash table
          so once again a data access exception is generated.
      12. hash_page() calls into __hash_page_thp() and inserts a mapping in the
          hash. Although the THP mapping maps 16M the hashing is done using 64K
          as the segment page size.
      13. hash_page() returns immediately after calling __hash_page_thp(), skipping
          over the code at line 1125. Resulting in the mismatch between the
          paca->context and mm->context not being detected.
      14. The hardware retries the access, the hash it generates using the 16M
          SLB entry does NOT match the hash we inserted.
      15. We take another data access and go into __hash_page_thp().
      16. We see a valid entry in the hpte_slot_array and so we call updatepp()
          which succeeds.
      17. Goto 14.
      
      We could fix this in two ways. The first would be to remove or modify
      the check on line 539 of slice.c.
      
      The second option is to cause the check of paca psize in hash_page() on
      line 1125 to also be done for THP pages.
      
      We prefer the latter, because the check & update of the paca psize is
      not done until we know it's necessary. It's also done only on the
      current cpu, so we don't need to IPI all other cpus.
      
      Without further rearranging the code, the simplest fix is to pull out
      the code that checks paca psize and call it in two places. Firstly for
      THP/hugetlb, and secondly for other mappings as before.
      
      Thanks to Dave Jones for trinity, which originally found this bug.
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Reviewed-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      0ddc881b
    • Gavin Shan's avatar
      powerpc/pseries: Fix overwritten PE state · a27d1641
      Gavin Shan authored
      commit 54f112a3 upstream.
      
      In pseries_eeh_get_state(), EEH_STATE_UNAVAILABLE is always
      overwritten by EEH_STATE_NOT_SUPPORT because of the missed
      "break" there. The patch fixes the issue.
      Reported-by: default avatarJoe Perches <joe@perches.com>
      Signed-off-by: default avatarGavin Shan <gwshan@linux.vnet.ibm.com>
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      a27d1641
    • Scott Mayhew's avatar
      nfs: Fix cache_validity check in nfs_write_pageuptodate() · b7c3aabc
      Scott Mayhew authored
      commit 18dd78c4 upstream.
      
      NFS_INO_INVALID_DATA cannot be ignored, even if we have a delegation.
      
      We're still having some problems with data corruption when multiple
      clients are appending to a file and those clients are being granted
      write delegations on open.
      
      To reproduce:
      
      Client A:
      vi /mnt/`hostname -s`
      while :; do echo "XXXXXXXXXXXXXXX" >>/mnt/file; sleep $(( $RANDOM % 5 )); done
      
      Client B:
      vi /mnt/`hostname -s`
      while :; do echo "YYYYYYYYYYYYYYY" >>/mnt/file; sleep $(( $RANDOM % 5 )); done
      
      What's happening is that in nfs_update_inode() we're recognizing that
      the file size has changed and we're setting NFS_INO_INVALID_DATA
      accordingly, but then we ignore the cache_validity flags in
      nfs_write_pageuptodate() because we have a delegation.  As a result,
      in nfs_updatepage() we're extending the write to cover the full page
      even though we've not read in the data to begin with.
      Signed-off-by: default avatarScott Mayhew <smayhew@redhat.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      b7c3aabc
    • Mateusz Guzik's avatar
      NFS: populate ->net in mount data when remounting · 708fc763
      Mateusz Guzik authored
      commit a914722f upstream.
      
      Otherwise the kernel oopses when remounting with IPv6 server because
      net is dereferenced in dev_get_by_name.
      
      Use net ns of current thread so that dev_get_by_name does not operate on
      foreign ns. Changing the address is prohibited anyway so this should not
      affect anything.
      Signed-off-by: default avatarMateusz Guzik <mguzik@redhat.com>
      Cc: linux-nfs@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      708fc763
    • Trond Myklebust's avatar
      NFS: Don't declare inode uptodate unless all attributes were checked · 9b8a9bf7
      Trond Myklebust authored
      commit 43b6535e upstream.
      
      Fix a bug, whereby nfs_update_inode() was declaring the inode to be
      up to date despite not having checked all the attributes.
      The bug occurs because the temporary variable in which we cache
      the validity information is 'sanitised' before reapplying to
      nfsi->cache_validity.
      Reported-by: default avatarKinglong Mee <kinglongmee@gmail.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      9b8a9bf7
    • Christoph Hellwig's avatar
      nfsd: getattr for FATTR4_WORD0_FILES_AVAIL needs the statfs buffer · 27b695cb
      Christoph Hellwig authored
      commit 12337901 upstream.
      
      Note nobody's ever noticed because the typical client probably never
      requests FILES_AVAIL without also requesting something else on the list.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      27b695cb
    • Trond Myklebust's avatar
      pNFS: Handle allocation errors correctly in filelayout_alloc_layout_hdr() · 803e56e2
      Trond Myklebust authored
      commit 6df200f5 upstream.
      
      Return the NULL pointer when the allocation fails.
      Reported-by: default avatarFengguang Wu <fengguang.wu@intel.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      803e56e2
    • Trond Myklebust's avatar
      SUNRPC: Fix a module reference leak in svc_handle_xprt · be03560f
      Trond Myklebust authored
      commit c789102c upstream.
      
      If the accept() call fails, we need to put the module reference.
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      be03560f
    • Bart Van Assche's avatar
      IB/umad: Fix use-after-free on close · 45c5cf39
      Bart Van Assche authored
      commit 60e1751c upstream.
      
      Avoid that closing /dev/infiniband/umad<n> or /dev/infiniband/issm<n>
      triggers a use-after-free.  __fput() invokes f_op->release() before it
      invokes cdev_put().  Make sure that the ib_umad_device structure is
      freed by the cdev_put() call instead of f_op->release().  This avoids
      that changing the port mode from IB into Ethernet and back to IB
      followed by restarting opensmd triggers the following kernel oops:
      
          general protection fault: 0000 [#1] PREEMPT SMP
          RIP: 0010:[<ffffffff810cc65c>]  [<ffffffff810cc65c>] module_put+0x2c/0x170
          Call Trace:
           [<ffffffff81190f20>] cdev_put+0x20/0x30
           [<ffffffff8118e2ce>] __fput+0x1ae/0x1f0
           [<ffffffff8118e35e>] ____fput+0xe/0x10
           [<ffffffff810723bc>] task_work_run+0xac/0xe0
           [<ffffffff81002a9f>] do_notify_resume+0x9f/0xc0
           [<ffffffff814b8398>] int_signal+0x12/0x17
      
      Reference: https://bugzilla.kernel.org/show_bug.cgi?id=75051Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Reviewed-by: default avatarYann Droneaud <ydroneaud@opteya.com>
      Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      45c5cf39