1. 30 Jan, 2015 4 commits
    • David Jeffery's avatar
      libata: prevent HSM state change race between ISR and PIO · 3142f62b
      David Jeffery authored
      commit ce751452 upstream.
      
      It is possible for ata_sff_flush_pio_task() to set ap->hsm_task_state to
      HSM_ST_IDLE in between the time __ata_sff_port_intr() checks for HSM_ST_IDLE
      and before it calls ata_sff_hsm_move() causing ata_sff_hsm_move() to BUG().
      
      This problem is hard to reproduce making this patch hard to verify, but this
      fix will prevent the race.
      
      I have not been able to reproduce the problem, but here is a crash dump from
      a 2.6.32 kernel.
      
      On examining the ata port's state, its hsm_task_state field has a value of HSM_ST_IDLE:
      
      crash> struct ata_port.hsm_task_state ffff881c1121c000
        hsm_task_state = 0
      
      Normally, this should not be possible as ata_sff_hsm_move() was called from ata_sff_host_intr(),
      which checks hsm_task_state and won't call ata_sff_hsm_move() if it has a HSM_ST_IDLE value.
      
      PID: 11053  TASK: ffff8816e846cae0  CPU: 0   COMMAND: "sshd"
       #0 [ffff88008ba03960] machine_kexec at ffffffff81038f3b
       #1 [ffff88008ba039c0] crash_kexec at ffffffff810c5d92
       #2 [ffff88008ba03a90] oops_end at ffffffff8152b510
       #3 [ffff88008ba03ac0] die at ffffffff81010e0b
       #4 [ffff88008ba03af0] do_trap at ffffffff8152ad74
       #5 [ffff88008ba03b50] do_invalid_op at ffffffff8100cf95
       #6 [ffff88008ba03bf0] invalid_op at ffffffff8100bf9b
          [exception RIP: ata_sff_hsm_move+317]
          RIP: ffffffff813a77ad  RSP: ffff88008ba03ca0  RFLAGS: 00010097
          RAX: 0000000000000000  RBX: ffff881c1121dc60  RCX: 0000000000000000
          RDX: ffff881c1121dd10  RSI: ffff881c1121dc60  RDI: ffff881c1121c000
          RBP: ffff88008ba03d00   R8: 0000000000000000   R9: 000000000000002e
          R10: 000000000001003f  R11: 000000000000009b  R12: ffff881c1121c000
          R13: 0000000000000000  R14: 0000000000000050  R15: ffff881c1121dd78
          ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
       #7 [ffff88008ba03d08] ata_sff_host_intr at ffffffff813a7fbd
       #8 [ffff88008ba03d38] ata_sff_interrupt at ffffffff813a821e
       #9 [ffff88008ba03d78] handle_IRQ_event at ffffffff810e6ec0
      3142f62b
    • Jim Lin's avatar
      pinctrl: Fix two deadlocks · 2f5a8212
      Jim Lin authored
      commit db93facf upstream.
      
      This patch is to fix two deadlock cases.
      Deadlock 1:
      CPU #1
       pinctrl_register-> pinctrl_get ->
       create_pinctrl
       (Holding lock pinctrl_maps_mutex)
       -> get_pinctrl_dev_from_devname
       (Trying to acquire lock pinctrldev_list_mutex)
      CPU #0
       pinctrl_unregister
       (Holding lock pinctrldev_list_mutex)
       -> pinctrl_put ->> pinctrl_free ->
       pinctrl_dt_free_maps -> pinctrl_unregister_map
       (Trying to acquire lock pinctrl_maps_mutex)
      
      Simply to say
      CPU#1 is holding lock A and trying to acquire lock B,
      CPU#0 is holding lock B and trying to acquire lock A.
      
      Deadlock 2:
      CPU #3
       pinctrl_register-> pinctrl_get ->
       create_pinctrl
       (Holding lock pinctrl_maps_mutex)
       -> get_pinctrl_dev_from_devname
       (Trying to acquire lock pinctrldev_list_mutex)
      CPU #2
       pinctrl_unregister
       (Holding lock pctldev->mutex)
       -> pinctrl_put ->> pinctrl_free ->
       pinctrl_dt_free_maps -> pinctrl_unregister_map
       (Trying to acquire lock pinctrl_maps_mutex)
      CPU #0
       tegra_gpio_request
       (Holding lock pinctrldev_list_mutex)
       -> pinctrl_get_device_gpio_range
       (Trying to acquire lock pctldev->mutex)
      
      Simply to say
      CPU#3 is holding lock A and trying to acquire lock D,
      CPU#2 is holding lock B and trying to acquire lock A,
      CPU#0 is holding lock D and trying to acquire lock B.
      Signed-off-by: default avatarJim Lin <jilin@nvidia.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2f5a8212
    • Johan Hovold's avatar
      gpio: sysfs: fix gpio device-attribute leak · ff82fa87
      Johan Hovold authored
      commit 0915e6fe upstream.
      
      The gpio device attributes were never destroyed when the gpio was
      unexported (or on export failures).
      
      Use device_create_with_groups() to create the default device attributes
      of the gpio class device. Note that this also fixes the
      attribute-creation race with userspace for these attributes.
      
      Remove contingent attributes in export error path and on unexport.
      
      Fixes: d8f388d8 ("gpio: sysfs interface")
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ff82fa87
    • Johan Hovold's avatar
      gpio: sysfs: fix gpio-chip device-attribute leak · 8345de68
      Johan Hovold authored
      commit 121b6a79 upstream.
      
      The gpio-chip device attributes were never destroyed when the device was
      removed.
      
      Fix by using device_create_with_groups() to create the device attributes
      of the chip class device.
      
      Note that this also fixes the attribute-creation race with userspace.
      
      Fixes: d8f388d8 ("gpio: sysfs interface")
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      8345de68
  2. 27 Jan, 2015 36 commits