From patchwork Fri Feb 10 11:51:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalle Valo X-Patchwork-Id: 9566623 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DC34D601C3 for ; Fri, 10 Feb 2017 11:52:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C670D2808F for ; Fri, 10 Feb 2017 11:52:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B86BD283EE; Fri, 10 Feb 2017 11:52:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 395432808F for ; Fri, 10 Feb 2017 11:52:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752875AbdBJLwC (ORCPT ); Fri, 10 Feb 2017 06:52:02 -0500 Received: from wolverine02.qualcomm.com ([199.106.114.251]:31345 "EHLO wolverine02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752848AbdBJLwB (ORCPT ); Fri, 10 Feb 2017 06:52:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qca.qualcomm.com; i=@qca.qualcomm.com; q=dns/txt; s=qcdkim; t=1486727521; x=1518263521; h=subject:from:to:cc:date:message-id:mime-version: content-transfer-encoding; bh=FmwNyHjK3v/RwNl7Du/2jK01sNFkGKw8QhZkidwn/3Q=; b=lWUswg8/6ub0JhK2NUMBDAXfTpxekDOR4TMw6gzYlZ9CKq8WT/88dCsu eLLDP5QCr031MD5ZtftgYeOkwhiXMaU/Res1dmOi2ZVxyHj7Lk6/U8XgG RCTv9SX/jMo/WLUGo+ZJfDNul3KAxFxxBF9F+MR3/wWQXFjf+t1V7tRAE 4=; X-IronPort-AV: E=Sophos;i="5.35,141,1484035200"; d="scan'208";a="357184487" Received: from unknown (HELO Ironmsg03-R.qualcomm.com) ([10.53.140.107]) by wolverine02.qualcomm.com with ESMTP; 10 Feb 2017 03:51:57 -0800 X-IronPort-AV: E=McAfee;i="5800,7501,8434"; a="1306930071" Received: from nasanexm02g.na.qualcomm.com ([10.85.0.88]) by Ironmsg03-R.qualcomm.com with ESMTP/TLS/RC4-SHA; 10 Feb 2017 03:51:57 -0800 Received: from eusanexr01a.eu.qualcomm.com (10.85.0.97) by nasanexm02g.na.qualcomm.com (10.85.0.88) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Fri, 10 Feb 2017 03:51:57 -0800 Received: from potku.adurom.net (10.80.80.8) by eusanexr01a.eu.qualcomm.com (10.85.0.97) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Fri, 10 Feb 2017 03:51:54 -0800 Subject: [PATCH v4] ath10k: fix napi crash during rmmod when probe firmware fails From: Kalle Valo To: CC: Date: Fri, 10 Feb 2017 13:51:25 +0200 Message-ID: <148672748569.28126.12259592472689214081.stgit@potku.adurom.net> User-Agent: StGit/0.17.1-17-ge4e0 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: NASANEXM01B.na.qualcomm.com (10.85.0.82) To eusanexr01a.eu.qualcomm.com (10.85.0.97) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This fixes the below crash when ath10k probe firmware fails, NAPI polling tries to access a rx ring resource which was never allocated. An easy way to reproduce this is easy to remove all the firmware files, load ath10k modules and ath10k will crash when calling 'rmmod ath10k_pci'. The fix is to call napi_enable() from ath10k_pci_hif_start() so that it matches with napi_disable() being called from ath10k_pci_hif_stop(). Big thanks to Mohammed Shafi Shajakhan who debugged this and provided first version of the fix. In this patch I just fix the actual problem in pci.c instead of having a workaround in core.c. BUG: unable to handle kernel NULL pointer dereference at (null) IP: __ath10k_htt_rx_ring_fill_n+0x19/0x230 [ath10k_core] __ath10k_htt_rx_ring_fill_n+0x19/0x230 [ath10k_core] Call Trace: [] ath10k_htt_rx_msdu_buff_replenish+0x42/0x90 [ath10k_core] [] ath10k_htt_txrx_compl_task+0x433/0x17d0 [ath10k_core] [] ? __wake_up_common+0x4d/0x80 [] ? cpu_load_update+0xdc/0x150 [] ? ath10k_pci_read32+0xd/0x10 [ath10k_pci] [] ath10k_pci_napi_poll+0x47/0x110 [ath10k_pci] [] net_rx_action+0x20f/0x370 Reported-by: Ben Greear Fixes: 3c97f5de1f28 ("ath10k: implement NAPI support") Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath10k/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index 5d2f9b9922d3..6094372307aa 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -1651,6 +1651,8 @@ static int ath10k_pci_hif_start(struct ath10k *ar) ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif start\n"); + napi_enable(&ar->napi); + ath10k_pci_irq_enable(ar); ath10k_pci_rx_post(ar); @@ -2535,7 +2537,6 @@ static int ath10k_pci_hif_power_up(struct ath10k *ar) ath10k_err(ar, "could not wake up target CPU: %d\n", ret); goto err_ce; } - napi_enable(&ar->napi); return 0;