Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1492714rdd; Thu, 11 Jan 2024 00:16:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIz4FwH9TSTh4aBP9bMwrYkqDpQWeOosOIwfWQINy18MJNYPVQibF52b3nk7pMknwUPKkT X-Received: by 2002:a17:90a:9c17:b0:28b:e74f:b7f7 with SMTP id h23-20020a17090a9c1700b0028be74fb7f7mr610486pjp.90.1704961004258; Thu, 11 Jan 2024 00:16:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704961004; cv=none; d=google.com; s=arc-20160816; b=TzE/S3gh1DenVvJkDMAf94pYLWPif2YpKKGlo1f3I+kgE/bx48m0bRrnE2wQ7d+rDz 8GvsjtxjzF+TM0Nm6qGnWiWy1Lj5RWOBWR9F08CrDDrKMZAl6SWu2G84x+PSiRCdtt6Y 5W9LdU7iGiSS6Sp9Df6PsQu1ykkaeUSop08GRfJag6UC+ukevYJk20UNrsk4jCKrh/xf Tw9Fszkf8SU4RHzzr5fKEk99Dv3uzv7FRuYPw14gmDU54fwB9y+aHtHJ+kFS2cP0cxPn U1hcM5NuccbceS/+sjNlXAqnEsApic0w0Wer8Ww1msls89AYBFUtJiMRH1o/O3JTdvF9 Nnog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from:dkim-signature; bh=ZoOpTDkO3PZHFU5dQRmU3J9Ylc/ozw3QutY0nMOReec=; fh=snMAx6ZMvk58khN8o3qFc6dT9Ct1xoDprtF5YEEmf5c=; b=0zG1Lsb0IuwykTgQqSeUNiz6dr6fXYwNWD9KyaIDJTZcxm2SaMDxXGUIYvUc9G8o3/ uZ62aTCK+pql+WrbJtHgp5mMsdmuO4P8cK8JrDy7mgOtEJXXwf7EFGIhRXjSLOT/Ji2j aIEdFg0N5Fu333DqPTiVCt6WXezOBXM9A2oOrMRQ0qZsbpEUAz/PJCpUMhqKCurQOEEU w3H6GN+lBLbqKOlhyA3J2OcZ3xF3jgrLYNw5+uKlXxqpy8dgY//fSp1KV0yWczqR9z1J Mq9Kf37Y0OGCaXW1z9rU4UBIxNV+mmPlnoq3N1V63Gkv6zRKECqXmTusLgWg/LER6r+l SQGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Uwu1Q7XX; spf=pass (google.com: domain of linux-bluetooth+bounces-1036-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1036-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j8-20020a17090a734800b0028bbd74af16si614260pjs.69.2024.01.11.00.16.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 00:16:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-1036-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Uwu1Q7XX; spf=pass (google.com: domain of linux-bluetooth+bounces-1036-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1036-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D3DEC2856C6 for ; Thu, 11 Jan 2024 08:16:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 31A83DDB3; Thu, 11 Jan 2024 08:16:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="Uwu1Q7XX" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0B32F9D2; Thu, 11 Jan 2024 08:16:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40B7TYrl003904; Thu, 11 Jan 2024 08:16:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:mime-version:content-type; s= qcppdkim1; bh=ZoOpTDkO3PZHFU5dQRmU3J9Ylc/ozw3QutY0nMOReec=; b=Uw u1Q7XX/4351c6TZfTAn0jKRaFDGJeH2FohuiGDeUzqXBLI8dWJUObveH3PYJKr/A zRPYMXuBq9uK5oJmwQagJgXeXEqgSsYyPQTXWHzJVFzGEZHwiO7lxsAjvTPbvU8k PgnVq7fz4q17rXHXJ3I6iq5jr9glBv7Vnt2b4eGbqjJe2Dz/+P5nCkXnjnSp7+pm meSCut7eOudJTHuLSAygoKw/RYz94PfQnts4cg/Wt9HYcOSXDHTSNEy8Z1uVIyZ0 v/Ek2ydGKkfeFPRFWkPt2SH7+hTFdM/R1TwbSHJ9Qxr36Zn7x1Dw9cq1KRHkKh1O y8lxV/GDhxbGcRGMGE6w== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vhsqytp96-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 08:16:26 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40B8GOMC015570 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 08:16:24 GMT Received: from zijuhu-gv.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Jan 2024 00:16:23 -0800 From: Zijun Hu To: , , CC: , , Subject: [PATCH v1] Bluetooth: qca: Fix crash when btattach controller ROME Date: Thu, 11 Jan 2024 16:16:18 +0800 Message-ID: <1704960978-5437-1-git-send-email-quic_zijuhu@quicinc.com> X-Mailer: git-send-email 2.7.4 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: sMbQPrTlxl-qBcTzGDJhAYj39sy80rSu X-Proofpoint-ORIG-GUID: sMbQPrTlxl-qBcTzGDJhAYj39sy80rSu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 clxscore=1011 phishscore=0 adultscore=0 mlxlogscore=846 spamscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401110065 A crash will happen when btattach controller ROME, and it is caused by dereferring nullptr hu->serdev, fixed by null check before access. sudo btattach -B /dev/ttyUSB0 -P qca Bluetooth: hci1: QCA setup on UART is completed BUG: kernel NULL pointer dereference, address: 00000000000002f0 ...... Workqueue: hci1 hci_power_on [bluetooth] RIP: 0010:qca_setup+0x7c1/0xe30 [hci_uart] ...... Call Trace: ? show_regs+0x72/0x90 ? __die+0x25/0x80 ? page_fault_oops+0x154/0x4c0 ? srso_alias_return_thunk+0x5/0xfbef5 ? kmem_cache_alloc+0x16b/0x310 ? do_user_addr_fault+0x330/0x6e0 ? srso_alias_return_thunk+0x5/0xfbef5 ? exc_page_fault+0x84/0x1b0 ? asm_exc_page_fault+0x27/0x30 ? qca_setup+0x7c1/0xe30 [hci_uart] hci_uart_setup+0x5c/0x1a0 [hci_uart] hci_dev_open_sync+0xee/0xca0 [bluetooth] hci_dev_do_open+0x2a/0x70 [bluetooth] hci_power_on+0x46/0x210 [bluetooth] process_one_work+0x17b/0x360 worker_thread+0x307/0x430 ? __pfx_worker_thread+0x10/0x10 kthread+0xf7/0x130 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x46/0x70 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1b/0x30 Fixes: 03b0093f7b31 ("Bluetooth: hci_qca: get wakeup status from serdev device handle") Cc: Signed-off-by: Zijun Hu Tested-by: Zijun Hu --- drivers/bluetooth/hci_qca.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 94b8c406f0c0..6fcfc1f7bb12 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -1951,7 +1951,7 @@ static int qca_setup(struct hci_uart *hu) qca_debugfs_init(hdev); hu->hdev->hw_error = qca_hw_error; hu->hdev->cmd_timeout = qca_cmd_timeout; - if (device_can_wakeup(hu->serdev->ctrl->dev.parent)) + if (hu->serdev && device_can_wakeup(hu->serdev->ctrl->dev.parent)) hu->hdev->wakeup = qca_wakeup; } else if (ret == -ENOENT) { /* No patch/nvm-config found, run with original fw/config */ -- 2.7.4