Skip to content

Commit

Permalink
Bluetooth: hci_serdev: Only unregister device if it was registered
Browse files Browse the repository at this point in the history
[ Upstream commit 202798db9570104728dce8bb57dfeed47ce764bc ]

We should not call hci_unregister_dev if the device was not
successfully registered.

Fixes: c34dc3b ("Bluetooth: hci_serdev: Introduce hci_uart_unregister_device()")
Signed-off-by: Nicolas Boichat <[email protected]>
Signed-off-by: Marcel Holtmann <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
drinkcat authored and gregkh committed Aug 19, 2020
1 parent a8acb2b commit d30d211
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/bluetooth/hci_serdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ void hci_uart_unregister_device(struct hci_uart *hu)
struct hci_dev *hdev = hu->hdev;

clear_bit(HCI_UART_PROTO_READY, &hu->flags);
hci_unregister_dev(hdev);
if (test_bit(HCI_UART_REGISTERED, &hu->flags))
hci_unregister_dev(hdev);
hci_free_dev(hdev);

cancel_work_sync(&hu->write_work);
Expand Down

0 comments on commit d30d211

Please sign in to comment.