• Matt Reynolds's avatar
    [gamepad] Fix Joy-Con Charging Grip disconnection crash · b4644a8f
    Matt Reynolds authored
    This CL avoids a crash when disconnecting a Joy-Con Charging
    Grip gamepad. The Joy-Con Charging Grip is a USB-C device that
    docks with two Nintendo Switch Joy-Cons and allows them to
    behave like a single USB gamepad.
    
    When disconnecting, NintendoDataFetcher::RemoveDevice decomposes
    the gamepad representing the charging grip into its Joy-Con
    subcomponents (composite_left_ and composite_right_). The parent
    device is then shut down, which may trigger a "stop vibration"
    command. This causes a null dereference when it tries to forward
    the vibration command to the subcomponent.
    
    To fix, the vibration command is sent before the subcomponents
    have been removed from the parent device and additional checks
    are added to ensure the subcomponents are not dereferenced after
    the parent is decomposed.
    
    BUG=995548
    
    Change-Id: I1d82e423b134ab3c99dd1e98a6615555cfadd47e
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1758980Reviewed-by: default avatarOvidio de Jesús Ruiz-Henríquez <odejesush@chromium.org>
    Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#691885}
    b4644a8f
nintendo_controller.cc 66 KB