From: Jun Nie Date: Tue, 7 Dec 2010 06:03:38 +0000 (+0800) Subject: Bluetooth: add NULL pointer check in HCI X-Git-Tag: v2.6.34.15~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f5e81c11b5d490009d2c51e929e4aaa317df121;p=thirdparty%2Fkernel%2Fstable.git Bluetooth: add NULL pointer check in HCI commit d9319560b86839506c2011346b1f2e61438a3c73 upstream. 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 Signed-off-by: Paul Gortmaker --- diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 283b127cea743..91be8d53d8195 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -313,8 +313,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); + } } } }