• Hans de Goede's avatar
    Bluetooth: hci_event: Fix vendor (unknown) opcode status handling · b82a26d8
    Hans de Goede authored
    Commit c8992cff ("Bluetooth: hci_event: Use of a function table to
    handle Command Complete") was (presumably) meant to only refactor things
    without any functional changes.
    
    But it does have one undesirable side-effect, before *status would always
    be set to skb->data[0] and it might be overridden by some of the opcode
    specific handling. While now it always set by the opcode specific handlers.
    This means that if the opcode is not known *status does not get set any
    more at all!
    
    This behavior change has broken bluetooth support for BCM4343A0 HCIs,
    the hci_bcm.c code tries to configure UART attached HCIs at a higher
    baudraute using vendor specific opcodes. The BCM4343A0 does not
    support this and this used to simply fail:
    
    [   25.646442] Bluetooth: hci0: BCM: failed to write clock (-56)
    [   25.646481] Bluetooth: hci0: Failed to set baudrate
    
    After which things would continue with the initial baudraute. But now
    that hci_cmd_complete_evt() no longer sets status for unknown opcodes
    *status is left at 0. This causes the hci_bcm.c code to think the baudraute
    has been changed on the HCI side and to also adjust the UART baudrate,
    after which communication with the HCI is broken, leading to:
    
    [   28.579042] Bluetooth: hci0: command 0x0c03 tx timeout
    [   36.961601] Bluetooth: hci0: BCM: Reset failed (-110)
    
    And non working bluetooth. Fix this by restoring the previous
    default "*status = skb->data[0]" handling for unknown opcodes.
    
    Fixes: c8992cff ("Bluetooth: hci_event: Use of a function table to handle Command Complete")
    Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
    Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
    b82a26d8
hci_event.c 190 KB