From patchwork Fri Mar 15 05:19:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Lu X-Patchwork-Id: 10854071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D4EA1669 for ; Fri, 15 Mar 2019 05:19:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 702062914E for ; Fri, 15 Mar 2019 05:19:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61861291F3; Fri, 15 Mar 2019 05:19:21 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 068322914E for ; Fri, 15 Mar 2019 05:19:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=50vds5162wRWMO5x+KlKCTab+DquhmK9lcCo9S1O1kM=; b=kDe 3ys6KRlYSCZwqIXf4p/YPeuvTCkq3+tH/fyFBkkx9Q9mVk34mCKSjgidQuaer/gZinZiCdmxmBuVq EszVvYmzbCCZ1lOLLWij513d2XY7PPt9ZBMkzjGvlPMUiGrBvNF1D6Uh4q4a4JkxjhcialswDBPAm 38jZuCwFmXbJ66T3TqaRbLiNfauww6OsGPxISEiwrMQ9kfqcN41wUfnACIW9/eZe/LakkGm9HO5in Lngayx1e/+LGnDM7IdrKeOmqCTT5mwvrQVFFzq/WOJSYm+pjb7NeXUz6BHtkSi3ldWenDzBjILMpJ b3wS9+I0obDMzz59DKG3qK4Nfad3chg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h4fFU-0005De-VN; Fri, 15 Mar 2019 05:19:16 +0000 Received: from mta-p5.oit.umn.edu ([134.84.196.205]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h4fFS-00052m-JT for ath10k@lists.infradead.org; Fri, 15 Mar 2019 05:19:16 +0000 Received: from localhost (unknown [127.0.0.1]) by mta-p5.oit.umn.edu (Postfix) with ESMTP id 5D7FDA7F for ; Fri, 15 Mar 2019 05:19:10 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p5.oit.umn.edu ([127.0.0.1]) by localhost (mta-p5.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bbzKvr13ka82 for ; Fri, 15 Mar 2019 00:19:10 -0500 (CDT) Received: from mail-it1-f199.google.com (mail-it1-f199.google.com [209.85.166.199]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p5.oit.umn.edu (Postfix) with ESMTPS id 251FED30 for ; Fri, 15 Mar 2019 00:19:10 -0500 (CDT) Received: by mail-it1-f199.google.com with SMTP id j127so6764420itj.7 for ; Thu, 14 Mar 2019 22:19:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=j6U+y4iY6osT5hFspHyeI/vwu/lDKXRQlpMa/rD0jqM=; b=UY/qewNhGz4utE7ET1BCB4W5qFAv9i/7Ym8Kw+LRwCcnUAtGFZTsGqLboUPZBk3zD8 NzSeeYN8KEk/a0aSTPHEL9yECaerc0sxDJZDOLOc3fkbyvsBKOVloEOZgzmW8XVxxF5v SxLGn0+J1zW1vvhFzzDTTSX+8ODPg7h2a570FG4+VGRpt1x6jYG3scXOdf6bsQWCi5yn WwcQkgsks/blMfe1pJmvEbKkdOW2IaV8ShnxizXFJHDv62UsiocKDmjLIcMJ1yk1DLKV oFMGRSVE+urfcFRcsjt40/Wa7qBBRPTVmrzRVGEBBD4xvAfrR1kWDUrpd28a/4q3yFem Gqgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=j6U+y4iY6osT5hFspHyeI/vwu/lDKXRQlpMa/rD0jqM=; b=mlFk2IcMHatdd+wN5YEGAZQ0UhVIsUY+3hnRbgyfLGH+scvkD4xHTHhEuoKbJ1zL3U zs8StFtyxSxH0b6uUFMMah6op95xabwsu+4KZEgehoSSzILD1B7dA33VS2HO1Bu/7wHW MRpBvJyznpdM0hZkDfVULzPgq3mhPlGgLNeK23LKAHqyCnVF0JqInBR0KH46ST12E9zR k6aPJ7BiJELMCOUUSKHWEeixJyfAfLU+pGPQLmkymi3UkOGRbYlderyB9SYFnCvBKzE5 iofLmqSwkDY7ZveAGj4SLd/zc5OVoPT16yd8f2OfzWQWV+SSIh0jkZknmjrgu3TTWUBj UVJQ== X-Gm-Message-State: APjAAAUsxAVq6mMfvckNdg1+YnI/W3jc2pIEOzmeDdrnZFqQdEA8YRHv UCkWZ8QJpIFrSkji9yjeosv8Z2kLYS/iv1OWs4kl5j4bORt4NNbIVIzp3OOCatdNdPnS5m8DsE8 I7t4t3Kq5J9yQlT6xseTwafDtQw== X-Received: by 2002:a24:418c:: with SMTP id b12mr841786itd.74.1552627149670; Thu, 14 Mar 2019 22:19:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNQimi15aoZT/w9cz7ZwWP0xM9MwZMlkkoQWsF9RX+9EIVw1Okv1h5KXV753E2PkvarZnfgQ== X-Received: by 2002:a24:418c:: with SMTP id b12mr841772itd.74.1552627149389; Thu, 14 Mar 2019 22:19:09 -0700 (PDT) Received: from bee.dtc.umn.edu (cs-bee-u.cs.umn.edu. [128.101.106.63]) by smtp.gmail.com with ESMTPSA id l134sm530985itb.12.2019.03.14.22.19.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Mar 2019 22:19:08 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Subject: [PATCH] net: ath: fix missing checks for bmi reads and writes Date: Fri, 15 Mar 2019 00:19:03 -0500 Message-Id: <20190315051903.10664-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190314_221914_751105_7FD220CE X-CRM114-Status: GOOD ( 12.61 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, ath10k@lists.infradead.org, pakki001@umn.edu, "David S. Miller" , Kalle Valo MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP ath10k_bmi_write32 and ath10k_bmi_read32 can fail. The fix checks their statuses to avoid potential undefined behaviors. Signed-off-by: Kangjie Lu --- drivers/net/wireless/ath/ath10k/core.c | 40 ++++++++++++++++++++------ 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index 835b8de92d55..1bb586f0040e 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -629,13 +629,20 @@ static void ath10k_send_suspend_complete(struct ath10k *ar) complete(&ar->target_suspend); } -static void ath10k_init_sdio(struct ath10k *ar) +static int ath10k_init_sdio(struct ath10k *ar) { + int ret; u32 param = 0; - ath10k_bmi_write32(ar, hi_mbox_io_block_sz, 256); - ath10k_bmi_write32(ar, hi_mbox_isr_yield_limit, 99); - ath10k_bmi_read32(ar, hi_acs_flags, ¶m); + ret = ath10k_bmi_write32(ar, hi_mbox_io_block_sz, 256); + if (ret) + return ret; + ret = ath10k_bmi_write32(ar, hi_mbox_isr_yield_limit, 99); + if (ret) + return ret; + ret = ath10k_bmi_read32(ar, hi_acs_flags, ¶m); + if (ret) + return ret; /* Data transfer is not initiated, when reduced Tx completion * is used for SDIO. disable it until fixed @@ -647,14 +654,22 @@ static void ath10k_init_sdio(struct ath10k *ar) */ param &= ~HI_ACS_FLAGS_ALT_DATA_CREDIT_SIZE; param |= HI_ACS_FLAGS_SDIO_SWAP_MAILBOX_SET; - ath10k_bmi_write32(ar, hi_acs_flags, param); + ret = ath10k_bmi_write32(ar, hi_acs_flags, param); + if (ret) + return ret; /* Explicitly set fwlog prints to zero as target may turn it on * based on scratch registers. */ - ath10k_bmi_read32(ar, hi_option_flag, ¶m); + ret = ath10k_bmi_read32(ar, hi_option_flag, ¶m); + if (ret) + return ret; param |= HI_OPTION_DISABLE_DBGLOG; - ath10k_bmi_write32(ar, hi_option_flag, param); + ret = ath10k_bmi_write32(ar, hi_option_flag, param); + if (ret) + return ret; + + return 0; } static int ath10k_init_configure_target(struct ath10k *ar) @@ -2500,8 +2515,15 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode, if (status) goto err; - if (ar->hif.bus == ATH10K_BUS_SDIO) - ath10k_init_sdio(ar); + if (ar->hif.bus == ATH10K_BUS_SDIO) { + status = ath10k_init_sdio(ar); + if (status) { + ath10k_err(ar, + "could not init HTC (%d)\n", + status); + goto err; + } + } } ar->htc.htc_ops.target_send_suspend_complete =