From: Jun Nie Date: Tue, 7 Dec 2010 06:03:38 +0000 (+0800) Subject: Bluetooth: add NULL pointer check in HCI X-Git-Tag: firefly_0821_release~7613^2~3176^2~7^2~8^2 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d9319560b86839506c2011346b1f2e61438a3c73;p=firefly-linux-kernel-4.4.55.git Bluetooth: add NULL pointer check in HCI If we fail to find a hci device pointer in hci_uart, don't try to deref the NULL one we do have. Signed-off-by: Jun Nie Signed-off-by: Gustavo F. Padovan --- diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 720148294e64..3c6cabcb7d84 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -311,8 +311,10 @@ static void hci_uart_tty_close(struct tty_struct *tty) if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) { hu->proto->close(hu); - hci_unregister_dev(hdev); - hci_free_dev(hdev); + if (hdev) { + hci_unregister_dev(hdev); + hci_free_dev(hdev); + } } } }