From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941546AbcIHOmC (ORCPT ); Thu, 8 Sep 2016 10:42:02 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:51322 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758550AbcIHOl7 (ORCPT ); Thu, 8 Sep 2016 10:41:59 -0400 From: Amitkumar Karwar To: CC: , , , Ganapathi Bhat , Amitkumar Karwar Subject: [PATCH v13 2/3] Bluetooth: hci_uart: check if hdev is present before using it Date: Thu, 8 Sep 2016 20:11:14 +0530 Message-ID: <1473345675-10995-2-git-send-email-akarwar@marvell.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1473345675-10995-1-git-send-email-akarwar@marvell.com> References: <1473345675-10995-1-git-send-email-akarwar@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-09-08_08:,, signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1609080213 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ganapathi Bhat The hdev struct might not have initialized in protocol receive handler. This patch adds necessary checks. Signed-off-by: Ganapathi Bhat Signed-off-by: Amitkumar Karwar --- drivers/bluetooth/hci_ldisc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index d7184dc..2c88586 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -154,7 +154,9 @@ restart: set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); len = tty->ops->write(tty, skb->data, skb->len); - hdev->stat.byte_tx += len; + + if (hdev) + hdev->stat.byte_tx += len; skb_pull(skb, len); if (skb->len) { @@ -349,7 +351,7 @@ void hci_uart_set_baudrate(struct hci_uart *hu, unsigned int speed) /* tty_set_termios() return not checked as it is always 0 */ tty_set_termios(tty, &ktermios); - BT_DBG("%s: New tty speeds: %d/%d", hu->hdev->name, + BT_DBG("%s: New tty speeds: %d/%d", hu->hdev ? hu->hdev->name : "", tty->termios.c_ispeed, tty->termios.c_ospeed); } -- 1.8.1.4