Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1558103rdd; Thu, 11 Jan 2024 02:53:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IERKYNi2V6TYXCy0NQgCVl4kPlhzuno1bAmd5y5wrUdBwkv9sC9ekhc0k/twkw+Cf2JrbGZ X-Received: by 2002:a17:90b:4a4f:b0:28d:d995:d248 with SMTP id lb15-20020a17090b4a4f00b0028dd995d248mr822754pjb.6.1704970417358; Thu, 11 Jan 2024 02:53:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704970417; cv=none; d=google.com; s=arc-20160816; b=LhG5oARSjZEMCRgFy+Lm53xbAaRsh2TlKC7k+t0dkt9fvKHdMe7Yl6FJ8nRo5/V0Sx 8yqMeJtdDMlrxMw9E5hv2LIc4vRh9+39QNsfzrmwUn4ZYks5Shcmyk2Wo9MhJvKejEZf OM+mtUeIzt/WKdsw0xfnYLIoWerpHrNIYF8/C2LvRHKzcWh3YXZEuuVx1V0AFUC/HNxz VGTP/G9knrknKwWNtWPMuIDrq9EA1aTyczW2FgAPtnFofQNW82ANnmD1yaj0BuKj9kzt XJq+mFZoqoXQVmd1bPKSg5YtRMGarYZwHdreKzWHaM/HYNLVQRotm1TSSaWJhwR1I63w e8eQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fhW2Rd9c+yae/f0I2AxyqB5G4hBNo+cU6Dfw0WMIcro=; fh=snMAx6ZMvk58khN8o3qFc6dT9Ct1xoDprtF5YEEmf5c=; b=HsYn1MO/BGJ6TlxnmFUo3kPZyvQGk2NwpQMcw68iI7l2+R6SqhO8Gw+BbXVseCPo4Q LrGWDLn8MTRYNvH3kC5lUUKMBpOox5Od2evd9l9LpXNfvw6JcuvQI+Waz+LuuRQtlYNN +lC7hJsHAqHgWnWSGAt2IH2G3j3kyquLPbtEADtuSDX5bmpGZMXjmBXVM4bA26QoBhJD R/oOzu+76wb1bfBrimXFJUr53CQZyEQuNjL5S0M23T3FjhundClSmnV800NNK2wlWnnF 0ZrJZr/7wdh+np9xdpPYvk/q1z7TxXL5e1kJSfq89EwPmFZ0Us24teiPwuXRAJPNJO07 F10A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=OCIorzlf; spf=pass (google.com: domain of linux-bluetooth+bounces-1044-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1044-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u5-20020a656705000000b005cecc6097f2si882282pgf.895.2024.01.11.02.53.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 02:53:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-1044-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=OCIorzlf; spf=pass (google.com: domain of linux-bluetooth+bounces-1044-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1044-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id B79E4B2645D for ; Thu, 11 Jan 2024 10:50:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8220214F65; Thu, 11 Jan 2024 10:50:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="OCIorzlf" 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 573E514AB2; Thu, 11 Jan 2024 10:50:03 +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 (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40BAXrhI032505; Thu, 11 Jan 2024 10:49:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=fhW2Rd9c+yae/f0I2Axy qB5G4hBNo+cU6Dfw0WMIcro=; b=OCIorzlfJa79DKQnKiXU7gnk/44w54OoBb4O IJyFKHzKIKegI2sDolWRZz5LmEQaCT6PJDBxf9mTtkp222UIotz0+B4sApbp65Ex q5EWI/+piJmInT/NBtk5jSpZmK4xjOHZDBf/N9lBIU2QH3FUl1gC7gKjJEoTlDow ejBwSNy/y0JADtSd7B/8Xd5YfeOKMzRASJda6UwtMNJEamqF1XZv6GdjgMoGIloj cDkZerb7XKhcDj4cAznNXLhl0OQ2pS2q3wFMye2sB1c/nOnDw0+JZ1f+RdNpk3rl 9T7DyfWn3RAxHGP5mM76lg1XzEkIaP66pj8vF7GzUBXyNUplgA== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vj0sk9qtu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 10:49:59 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40BAnwkl030136 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 10:49:58 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 02:49:56 -0800 From: Zijun Hu To: , , CC: , , Subject: [PATCH v2] Bluetooth: qca: Fix crash when btattach BT controller QCA_ROME Date: Thu, 11 Jan 2024 18:49:41 +0800 Message-ID: <1704970181-30092-1-git-send-email-quic_zijuhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1704960978-5437-1-git-send-email-quic_zijuhu@quicinc.com> References: <1704960978-5437-1-git-send-email-quic_zijuhu@quicinc.com> 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: mRDApUkr9_-VP3OfsXS3GwxO9gjOsRa_ X-Proofpoint-ORIG-GUID: mRDApUkr9_-VP3OfsXS3GwxO9gjOsRa_ 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 clxscore=1015 adultscore=0 suspectscore=0 impostorscore=0 malwarescore=0 mlxlogscore=945 bulkscore=0 lowpriorityscore=0 spamscore=0 phishscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401110087 A crash will happen when use tool btattach to attach a BT controller QCA_ROME, and it is caused by dereferencing 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 --- Changes since v1: - Correct tile and commit message based on Paul's suggestions 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