From patchwork Thu Aug 1 07:01:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anilkumar Kolli X-Patchwork-Id: 11070187 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-2.web.codeaurora.org (Postfix) with ESMTP id 745BE13A4 for ; Thu, 1 Aug 2019 07:02:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 656D02845E for ; Thu, 1 Aug 2019 07:02:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 597672847A; Thu, 1 Aug 2019 07:02:29 +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=ham 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 E5D982845E for ; Thu, 1 Aug 2019 07:02:28 +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:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=sCNCbQcOtcM3hrkIcnrqcqthOGmIm2IDW9YQl3E8DE8=; b=quw3UbLi4rxh7A okomWRQ9mDQBipxTnE4hV9U8en0EOmbeaiD+AOFXnEBWPxOLnn0kxYukfRduJNqWWDmF9s/XR7kKK 6RrohRk1Bx8fBSeBuneSuSSVA6Tewk3V+X6GfZf/NrwsTktx+s0erf3M7D3NEwmigKbKkkAPuprnz TIA6vJy3+CSfEQdaCWD6y/vJUrb7JIjtNVBkrIuMrOMdySpn9XIvSxonmppDxESqBZZ6oap3lMCKM 5XsCxLvpzKF2G6nacSdC9J0675GmJPu4fx6VACDXZsBc6hF1VWNnXJdr9YgsVYZutxYU63CGGJL/J ZxgvXDbKWwtyu6zAgPwQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1ht56Z-0004QQ-Iq; Thu, 01 Aug 2019 07:02:27 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1ht56W-0004Q5-Fa for ath11k@lists.infradead.org; Thu, 01 Aug 2019 07:02:25 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 471A66055D; Thu, 1 Aug 2019 07:02:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1564642943; bh=RbIfFrccxquRYF8sGyTn+bLzzCTvjqfNWHmzrzRNXxU=; h=From:To:Cc:Subject:Date:From; b=chKVVOTzMxkFDzxmBQSL5kLAD6FFgIkG1Y8DVsismnc36QN+3m3b75jkHLHdQO8wE gZaSOQpNSdQfd4NM04wUk6jiksT+KnJ1tqW5RClyVrX/1vvyzYosp8JFrQAdq6QUAn 9dAfT2DrGOTQF5M4ysIuYPbHma5WierNkLpiGJDA= Received: from localhost (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: akolli@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 17D3860721; Thu, 1 Aug 2019 07:02:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1564642942; bh=RbIfFrccxquRYF8sGyTn+bLzzCTvjqfNWHmzrzRNXxU=; h=From:To:Cc:Subject:Date:From; b=j/FovN8Y3mbsf1L87SYsXYD7qsoBgmMvH5AL8rfMX+S6jg16T/ycxiymmTgBTtWqu oHFf7yktNv0YAiVE7rLHkU20/d0argKcZ7SogcZRUiUJpimXzT4jZ1/eH+Be/Vw4zF yz0RZrJ/hFScsz/Ju+tJ9hM8lcmQr1cauvWiWxb8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 17D3860721 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=akolli@codeaurora.org From: Anilkumar Kolli To: ath11k@lists.infradead.org Subject: [PATCH] ath11k: fix wmi service ready ext tlv parsing Date: Thu, 1 Aug 2019 12:31:56 +0530 Message-Id: <1564642916-4728-1-git-send-email-akolli@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190801_000224_597951_68946C6C X-CRM114-Status: GOOD ( 10.70 ) X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "ath11k" Errors-To: ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The current ath11k driver failed to parse wmi_tlv_svc_rdy_ext_parse if there is change in wmi_mac_phy_capabilities length with below error. ath11k c000000.wifi1: failed to extract mac caps, idx :0 ath11k c000000.wifi1: failed to parse tlv -22 Signed-off-by: Anilkumar Kolli --- drivers/net/wireless/ath/ath11k/wmi.c | 14 +++++++++++--- drivers/net/wireless/ath/ath11k/wmi.h | 1 - 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index 83310d6b6a0e..e46ba532a6a1 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -310,7 +310,7 @@ static int ath11k_pull_svc_ready_ext(struct ath11k_pdev_wmi *wmi_handle, if (phy_id >= hal_reg_caps->num_phy) return -EINVAL; - mac_phy_caps = &wmi_mac_phy_caps[phy_idx]; + mac_phy_caps = wmi_mac_phy_caps + phy_idx; pdev->pdev_id = mac_phy_caps->pdev_id; pdev_cap->supported_bands = mac_phy_caps->supported_bands; @@ -2837,6 +2837,15 @@ static int ath11k_wmi_tlv_mac_phy_caps_parse(struct ath11k_base *soc, if (svc_rdy_ext->n_mac_phy_caps >= svc_rdy_ext->tot_phy_id) return -ENOBUFS; + len = min_t(u16, len, sizeof(struct wmi_mac_phy_capabilities)); + if (!svc_rdy_ext->n_mac_phy_caps) { + svc_rdy_ext->mac_phy_caps = kzalloc((svc_rdy_ext->tot_phy_id) * len, + GFP_ATOMIC); + if (!svc_rdy_ext->mac_phy_caps) + return -ENOMEM; + } + + memcpy(svc_rdy_ext->mac_phy_caps + svc_rdy_ext->n_mac_phy_caps, ptr, len); svc_rdy_ext->n_mac_phy_caps++; return 0; } @@ -2970,8 +2979,6 @@ static int ath11k_wmi_tlv_svc_rdy_ext_parse(struct ath11k_base *ab, svc_rdy_ext->hw_mode_done = true; } else if (!svc_rdy_ext->mac_phy_done) { svc_rdy_ext->n_mac_phy_caps = 0; - svc_rdy_ext->mac_phy_caps = - (struct wmi_mac_phy_capabilities *)ptr; ret = ath11k_wmi_tlv_iter(ab, ptr, len, ath11k_wmi_tlv_mac_phy_caps_parse, svc_rdy_ext); @@ -3012,6 +3019,7 @@ static int ath11k_service_ready_ext_event(struct ath11k_base *ab, return ret; } + kfree(svc_rdy_ext.mac_phy_caps); return 0; } diff --git a/drivers/net/wireless/ath/ath11k/wmi.h b/drivers/net/wireless/ath/ath11k/wmi.h index 7d933eafd3cd..8b75b7f9aef1 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.h +++ b/drivers/net/wireless/ath/ath11k/wmi.h @@ -2241,7 +2241,6 @@ struct wmi_hw_mode_capabilities { #define WMI_MAX_HECAP_PHY_SIZE (3) struct wmi_mac_phy_capabilities { - u32 tlv_header; u32 hw_mode_id; u32 pdev_id; u32 phy_id;