From patchwork Sat Jan 11 09:08:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 11328753 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CB831398 for ; Sat, 11 Jan 2020 09:08:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 53F7A2072E for ; Sat, 11 Jan 2020 09:08:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="j0liM05K" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 53F7A2072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=r6pRvaXstfn/xxeEYC7PrdDBPN1sdZDCJ1yJ1niWzMA=; b=j0liM05KwKup4A yfkwL/btGLiM4FOxCDyE7mA8P+qV9WD/qVJu2QLi2F6RN5zkOsu0tCzKPz2hZPpGB8xEZOxq2PSGE iVWvrrW+9rcty4OS7ZNWKbiPqWjYWCd4VexxmAFNqZ1DPMlyr7ChyvBAHl3RaN7QRZNG9IGpG4y47 pc94y73Z5Y6C9x4XsuDYMkbSL1j5if0o/ej7sQ/eVgezOoso/DHKIbowibzn5qIvBGsLhEeOAxDsN nHG6OX3VvUaX5CIOXJOM5DInsQD7cPsFoO233sd05gNeCjOJ1AxVaaSmwAJ+jXRmXiNLs703vm0Kg /fM9EcAJ7b3i+M0jpuyg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iqCl1-0002eb-Bw; Sat, 11 Jan 2020 09:08:35 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iqCky-0002eA-Je for ath11k@lists.infradead.org; Sat, 11 Jan 2020 09:08:34 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iqCkq-0008P9-Ea; Sat, 11 Jan 2020 09:08:24 +0000 From: Colin King To: Kalle Valo , "David S . Miller" , John Crispin , Shashidhar Lakkavalli , ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH][next] ath11k: avoid null pointer dereference when pointer band is null Date: Sat, 11 Jan 2020 09:08:24 +0000 Message-Id: <20200111090824.9999-1-colin.king@canonical.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200111_010832_785063_B2193B99 X-CRM114-Status: UNSURE ( 8.75 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [91.189.89.112 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [91.189.89.112 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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: , Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Sender: "ath11k" Errors-To: ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org From: Colin Ian King In the unlikely event that cap->supported_bands has neither WMI_HOST_WLAN_2G_CAP set or WMI_HOST_WLAN_5G_CAP set then pointer band is null and a null dereference occurs when assigning band->n_iftype_data. Move the assignment to the if blocks to avoid this. Cleans up static analysis warnings. Addresses-Coverity: ("Explicit null dereference") Fixes: 9f056ed8ee01 ("ath11k: add HE support") Signed-off-by: Colin Ian King --- drivers/net/wireless/ath/ath11k/mac.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 556eef9881a7..4a364cfe37ed 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -3520,8 +3520,8 @@ static int ath11k_mac_copy_he_cap(struct ath11k *ar, static void ath11k_mac_setup_he_cap(struct ath11k *ar, struct ath11k_pdev_cap *cap) { - struct ieee80211_supported_band *band = NULL; - int count = 0; + struct ieee80211_supported_band *band; + int count; if (cap->supported_bands & WMI_HOST_WLAN_2G_CAP) { count = ath11k_mac_copy_he_cap(ar, cap, @@ -3529,6 +3529,7 @@ static void ath11k_mac_setup_he_cap(struct ath11k *ar, NL80211_BAND_2GHZ); band = &ar->mac.sbands[NL80211_BAND_2GHZ]; band->iftype_data = ar->mac.iftype[NL80211_BAND_2GHZ]; + band->n_iftype_data = count; } if (cap->supported_bands & WMI_HOST_WLAN_5G_CAP) { @@ -3537,9 +3538,8 @@ static void ath11k_mac_setup_he_cap(struct ath11k *ar, NL80211_BAND_5GHZ); band = &ar->mac.sbands[NL80211_BAND_5GHZ]; band->iftype_data = ar->mac.iftype[NL80211_BAND_5GHZ]; + band->n_iftype_data = count; } - - band->n_iftype_data = count; } static int __ath11k_set_antenna(struct ath11k *ar, u32 tx_ant, u32 rx_ant)