Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp177651imd; Wed, 31 Oct 2018 16:53:07 -0700 (PDT) X-Google-Smtp-Source: AJdET5dFv59J/Wro36VWcFpiixWsbVPMkzK/lLwq7PweqTShd5lAyYDOj+V7IXr8guGXNqagDo/Q X-Received: by 2002:a63:734e:: with SMTP id d14-v6mr5075116pgn.397.1541029986945; Wed, 31 Oct 2018 16:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029986; cv=none; d=google.com; s=arc-20160816; b=UmdfbbvyunWLcqHv6/sYKN2xE0QpmANbUYSnxKvu4csGouh2VjCumyJILvknvZZoK5 JOoTgOsmxM2gRhIVL59MNzb0fwQPPWK72fBGw+iy/JfJRsFMtFlgnH13CeyRGl6h3Xsp muOr0frT03z0iDyXwz6tO7jPqI7aPz/KMZmsUgMZqM2airAl3VzuSUXGkjgCyB/PD7xZ CurYF2r7qU86LUqXsi8QNQ9E/Br4r8sbYeY7AlkPNf5ap+G48M34GVq3Wgwe0m5Jddi2 TJgB2jnrrJXWH87M0aqbHc5fgsFG4p0790ZHiTXwINvLVdF5qya2RMUW+Iz0zC0cRsBK 6vAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=m4NAaXg1A1t+pr3LC1b8ytR6mLmRpm5EM3qewmf+hfg=; b=HWUJCFmnjSY8ANzrCvqDkxxgW5oVEpCbjxUlP3WtNHVs4mme1mkGQo2VB1mWg/DmV0 TnVMLzjSAuxUNGcYLCKPFFHUOUEbBCjDeajAPw5VaYM614FrcRGdQTNA2CLaynl6VJ5I FQg7MFDcIMN3qHRLele972Yk2UxkzLjYaVHXLMM3WWVLzb4QRqDkxVwDPHI4zqyBeJVf gTxvdvz0XlxPT7Nck5leZk4YEwvAR9THMyOWF4TH2jJSZ0nA0GEhKOfvkfkBlB1RLPvL 3oC/hitxjwJnKszkzhg4dDoCoxsPssEcteHgkbp7KH1+1BXH7VSRJ3TkgaPEMuBguCR+ ou3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DbUVqITB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si12148495pls.0.2018.10.31.16.52.44; Wed, 31 Oct 2018 16:53:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DbUVqITB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728350AbeKAIvd (ORCPT + 99 others); Thu, 1 Nov 2018 04:51:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:53560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728098AbeKAIGf (ORCPT ); Thu, 1 Nov 2018 04:06:35 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8946D20854; Wed, 31 Oct 2018 23:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027185; bh=iRbJlu+RCqB5NUUnNMVzp6yjzxF0vNrx9OAwzStowp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DbUVqITBODFPY6uJHmbVTbfUlucuDkmy3c4jWikfQRSRobBq59OXC/p9iwz4bE8FJ sOk9dxhFaCMvXVb6Il4WtT+4uZ/0Rs8cZ4d2JBImLu0+foP8KZ2coE46ZrPi+YUbD0 Aob4rjje2+6zRxaPLh9o+HrQm8UDJ751XPWy2otM= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Balakrishna Godavarthi , Marcel Holtmann , Sasha Levin Subject: [PATCH AUTOSEL 4.19 047/146] Bluetooth: hci_qca: Remove hdev dereference in qca_close(). Date: Wed, 31 Oct 2018 19:04:02 -0400 Message-Id: <20181031230541.28822-47-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Balakrishna Godavarthi [ Upstream commit c2d7827338618a9e73a3f892ca63d9082bb7a94d ] When flag KASAN is set, we are seeing an following crash while removing hci_uart module. [ 50.589909] Unable to handle kernel paging request at virtual address 6b6b6b6b6b6b73 [ 50.597902] Mem abort info: [ 50.600846] Exception class = DABT (current EL), IL = 32 bits [ 50.606959] SET = 0, FnV = 0 [ 50.610142] EA = 0, S1PTW = 0 [ 50.613396] Data abort info: [ 50.616401] ISV = 0, ISS = 0x00000004 [ 50.620373] CM = 0, WnR = 0 [ 50.623466] [006b6b6b6b6b6b73] address between user and kernel address ranges [ 50.630818] Internal error: Oops: 96000004 [#1] PREEMPT SMP [ 50.671670] PC is at qca_power_shutdown+0x28/0x100 [hci_uart] [ 50.677593] LR is at qca_close+0x74/0xb0 [hci_uart] [ 50.775689] Process rmmod (pid: 2144, stack limit = 0xffffff801ba90000) [ 50.782493] Call trace: [ 50.872150] [] qca_power_shutdown+0x28/0x100 [hci_uart] [ 50.879138] [] qca_close+0x74/0xb0 [hci_uart] [ 50.885238] [] hci_uart_unregister_device+0x44/0x50 [hci_uart] [ 50.892846] [] qca_serdev_remove+0x50/0x5c [hci_uart] [ 50.899654] [] serdev_drv_remove+0x28/0x38 [ 50.905489] [] device_release_driver_internal+0x140/0x1e4 [ 50.912653] [] driver_detach+0x78/0x84 [ 50.918121] [] bus_remove_driver+0x80/0xa8 [ 50.923942] [] driver_unregister+0x4c/0x58 [ 50.929768] [] qca_deinit+0x24/0x598 [hci_uart] [ 50.936045] [] hci_uart_exit+0x10/0x48 [hci_uart] [ 50.942495] [] SyS_delete_module+0x17c/0x224 This crash is due to dereference of hdev, after freeing it. Signed-off-by: Balakrishna Godavarthi Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- drivers/bluetooth/hci_qca.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 2fee65886d50..f0d593c3fa72 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -167,7 +167,7 @@ struct qca_serdev { }; static int qca_power_setup(struct hci_uart *hu, bool on); -static void qca_power_shutdown(struct hci_dev *hdev); +static void qca_power_shutdown(struct hci_uart *hu); static void __serial_clock_on(struct tty_struct *tty) { @@ -609,7 +609,7 @@ static int qca_close(struct hci_uart *hu) if (hu->serdev) { qcadev = serdev_device_get_drvdata(hu->serdev); if (qcadev->btsoc_type == QCA_WCN3990) - qca_power_shutdown(hu->hdev); + qca_power_shutdown(hu); else gpiod_set_value_cansleep(qcadev->bt_en, 0); @@ -1232,12 +1232,15 @@ static const struct qca_vreg_data qca_soc_data = { .num_vregs = 4, }; -static void qca_power_shutdown(struct hci_dev *hdev) +static void qca_power_shutdown(struct hci_uart *hu) { - struct hci_uart *hu = hci_get_drvdata(hdev); + struct serdev_device *serdev = hu->serdev; + unsigned char cmd = QCA_WCN3990_POWEROFF_PULSE; host_set_baudrate(hu, 2400); - qca_send_power_pulse(hdev, QCA_WCN3990_POWEROFF_PULSE); + hci_uart_set_flow_control(hu, true); + serdev_device_write_buf(serdev, &cmd, sizeof(cmd)); + hci_uart_set_flow_control(hu, false); qca_power_setup(hu, false); } @@ -1413,7 +1416,7 @@ static void qca_serdev_remove(struct serdev_device *serdev) struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev); if (qcadev->btsoc_type == QCA_WCN3990) - qca_power_shutdown(qcadev->serdev_hu.hdev); + qca_power_shutdown(&qcadev->serdev_hu); else clk_disable_unprepare(qcadev->susclk); -- 2.17.1