nfc: Fix hangup of RC-S380* in port100_send_ack()
authorOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Sat, 4 Feb 2017 01:16:56 +0000 (10:16 +0900)
committerSamuel Ortiz <sameo@linux.intel.com>
Sat, 1 Apr 2017 21:04:30 +0000 (23:04 +0200)
commit2497128133f8169b24b928852ba6eae34fc495e5
tree78d8aacc0bc93f1e3a426adcd8a470576c88801c
parent0ada076819529203e11fcd5d3d52a2c9ada21879
nfc: Fix hangup of RC-S380* in port100_send_ack()

If port100_send_ack() was called twice or more, it has race to hangup.

  port100_send_ack()          port100_send_ack()
    init_completion()
    [...]
    dev->cmd_cancel = true
                                /* this removes previous from completion */
                                init_completion()
[...]
                                dev->cmd_cancel = true
                                wait_for_completion()
    /* never be waked up */
    wait_for_completion()

Like above race, this code is not assuming port100_send_ack() is
called twice or more.

To fix, this checks dev->cmd_cancel to know if prior cancel is
in-flight or not. And never be remove prior task from completion by
using reinit_completion(), so this guarantees to be waked up properly
soon or later.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/port100.c