• Mathias Nyman's avatar
    xhci: Handle command completion and timeout race · 0ee71b22
    Mathias Nyman authored
    commit a5a1b951 upstream.
    
    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.
    Reported-by: default avatarBaolin Wang <baolin.wang@linaro.org>
    Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
    0ee71b22
xhci-ring.c 123 KB