Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp689549ybv; Thu, 13 Feb 2020 07:49:10 -0800 (PST) X-Google-Smtp-Source: APXvYqzp7Y53NUMkmSlxeSufmz9zphwnpweUbgU/fiilqyD4Yw+ovk2uvrrVmXk3fAqG2T/G9xBl X-Received: by 2002:a05:6830:1e2d:: with SMTP id t13mr14294166otr.128.1581608950673; Thu, 13 Feb 2020 07:49:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581608950; cv=none; d=google.com; s=arc-20160816; b=G0W9Lrek+FnP5F2hsWcDGKYRhiWS+PgPxLB1K5TbohnQGZ04NN/Fx4KLRA+hNXlPoV 63sVKrVKRsq9AKCA4fuZd2fCyAKJCGiH14ZAfNboa9mZwGMuePO2BR3pfq4S9GZqQ2UN FCuTjlfzsX+L7gHYPxy66CQs0PssQ7aQylIhC0gZWbvBC4sYiz+fX3bd9+n3gS2MpioV lkedUadjaad0q/Y1D50PmTSx/vwtSPl3VQawTIdHLZWOgoe/0O0VHNFhW5X/CDi5aeDK gNTLL4nXeJ8Fneqb9myijf0tFv8qtwEVG4wFbfyq7pXBfAXuYx5qzsKViebwuiV7w+kU xYSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WEj6D6nihdlnl41mU8Kt4EZZtcZpwjFyirEumiDNdYA=; b=V2X7fYFrPBw1AOam5pJ4tAN3/dOp00/QiYg+9JC29zcSRe/nfLpcOCGYaEm36hQMI9 w3hxrcZuWXS65zm08/WcktDVGooSdXbnbJLbNUvd4mT8XtUP0v97trTZgltpDeyTIX22 fMh8CQsZo04/LiHPlu8S54iN9bZ5ts+j78H8xsH9AqzXGTVgjPO4oPN8+peVxR09RVw5 H5V5NxeMZu+sSixlFiovUuGZfDFytev2yrjvgPn7IV7wc4sQEH/xrXnUvRtmpSEpNERN z/Idvn5nSD/vOLL19MavhvVzVE3J2iOun7nmSk7XjLi9uVj4uTI2R+2ZQxjMK3zygo5M pSFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=m2TspjOc; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x20si1105154otq.222.2020.02.13.07.48.57; Thu, 13 Feb 2020 07:49:10 -0800 (PST) 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=m2TspjOc; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729454AbgBMPrw (ORCPT + 99 others); Thu, 13 Feb 2020 10:47:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:47986 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728496AbgBMP1A (ORCPT ); Thu, 13 Feb 2020 10:27:00 -0500 Received: from localhost (unknown [104.132.1.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0BAC32468D; Thu, 13 Feb 2020 15:27:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607620; bh=I3F37xw90XR+ITkmYbUSU264wdX9jM9dM/02J2SyJLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m2TspjOcCQ9n9JadozBeoTf3IzjIA8SuLKl1kZC6omrVYLr34MxiN5wPa20cm0h0Q qmPlspNtkmKWYlWCEj/f57KNbERH89BnS/C7We6cuWOjhQO3RqMN8yVFHaQM8Po7w6 z1H+8ckTyhZVm5Vpl1q7cqkOIaZFeugCNxIiMggQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bryan ODonoghue , Kalle Valo Subject: [PATCH 5.4 14/96] ath10k: pci: Only dump ATH10K_MEM_REGION_TYPE_IOREG when safe Date: Thu, 13 Feb 2020 07:20:21 -0800 Message-Id: <20200213151844.830408523@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151839.156309910@linuxfoundation.org> References: <20200213151839.156309910@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bryan O'Donoghue commit d239380196c4e27a26fa4bea73d2bf994c14ec2d upstream. ath10k_pci_dump_memory_reg() will try to access memory of type ATH10K_MEM_REGION_TYPE_IOREG however, if a hardware restart is in progress this can crash a system. Individual ioread32() time has been observed to jump from 15-20 ticks to > 80k ticks followed by a secure-watchdog bite and a system reset. Work around this corner case by only issuing the read transaction when the driver state is ATH10K_STATE_ON. Tested-on: QCA9988 PCI 10.4-3.9.0.2-00044 Fixes: 219cc084c6706 ("ath10k: add memory dump support QCA9984") Signed-off-by: Bryan O'Donoghue Signed-off-by: Kalle Valo Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/ath/ath10k/pci.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -1604,11 +1604,22 @@ static int ath10k_pci_dump_memory_reg(st { struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); u32 i; + int ret; + + mutex_lock(&ar->conf_mutex); + if (ar->state != ATH10K_STATE_ON) { + ath10k_warn(ar, "Skipping pci_dump_memory_reg invalid state\n"); + ret = -EIO; + goto done; + } for (i = 0; i < region->len; i += 4) *(u32 *)(buf + i) = ioread32(ar_pci->mem + region->start + i); - return region->len; + ret = region->len; +done: + mutex_unlock(&ar->conf_mutex); + return ret; } /* if an error happened returns < 0, otherwise the length */ @@ -1704,7 +1715,11 @@ static void ath10k_pci_dump_memory(struc count = ath10k_pci_dump_memory_sram(ar, current_region, buf); break; case ATH10K_MEM_REGION_TYPE_IOREG: - count = ath10k_pci_dump_memory_reg(ar, current_region, buf); + ret = ath10k_pci_dump_memory_reg(ar, current_region, buf); + if (ret < 0) + break; + + count = ret; break; default: ret = ath10k_pci_dump_memory_generic(ar, current_region, buf);