Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp191847pxj; Tue, 18 May 2021 00:49:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQaoOZsAVCmPUR3w73hgzSaJCqVsVm8zLTj19GnWOitbUGSOYu7UhUU2P3/EzbjDkqdRWC X-Received: by 2002:a17:907:3f8a:: with SMTP id hr10mr4651705ejc.137.1621324144545; Tue, 18 May 2021 00:49:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621324144; cv=none; d=google.com; s=arc-20160816; b=AjurvlIJT59zp9M1Y5/RnIXtU6sC6y7ypu/Io6oY2IkYupLu5VskBmGNZWJ3kbACK5 TZlfhLgmk3eeGHROOYag2SL0xDDZ2nSEnTMfWRSCxnS39H+Dj69KV/MqW/XQ8GGiY31A qGtj0sGP4uMIm6Wilj+bLZL4WTUsjM1ezoTURUZBegIRSsz9qRyJsJWBpmq3P736g8dm LpzS0O5aM+7YvNNttojJA2DZ3qVAG04TKNqxZo7wslnWbU06f+chafio3V+7op9bD4r4 PORAMy89GDLannxDsDn8YTQ+tQBDEMp5tbz7XZilKnqdy48BXbV5+olnIUtT8L9IOMoE jlzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RJMZjscDAZUDilEfyNom33AlrDYedk6reEz6K+NzKE8=; b=ip3t/a1RCkUJxnRu8UBJPzJv5EB9HK0hm5jqKNMCGxJrFoVAj/MzjLcH/iht3dhpNx zCqI0OqiarlUqZCNpyNDvWIKcIPEwpeN5ifEpCC8mH1tvlsmuPvTZ0gIKEhgQY/7WuyV fspjZIFUJgZdZpQ/sOqc8OKTmDTs5Zbwhr0QeG/PyQbgWgPKjvo6FhOiM16ttncE67GS 4CbrhS9u0lBQMbYWI4d8LUFlNz/Yiq0gRC/Ia4VtIMO6mUJGjiJulhWN7qvEK7yGmW2y 17co2HaNrKZV7hGptuFKB0pZHIB8Kxjp7CC4+LPhxx6PgcpIfjpKQwR0sZimurZSxVMV We8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QEQt9o1V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bg21si17099925ejb.58.2021.05.18.00.48.41; Tue, 18 May 2021 00:49:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QEQt9o1V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241289AbhEQO6I (ORCPT + 99 others); Mon, 17 May 2021 10:58:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:39584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241197AbhEQOsj (ORCPT ); Mon, 17 May 2021 10:48:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3EB556196E; Mon, 17 May 2021 14:22:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261351; bh=dKodwKUoJASrAFlw1LNyG9ld/2oU3AxtzmUdjccQb24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QEQt9o1VYY+6nlTPfR4mm6BrqFf2EHsuss9cbdPnmOmvJIVvp/L1Z57+Q50J31ucz O7N0Red7Jg4TnjTJaSVMPqiqfWL1mDwGX1NFNf4sx6Oa3/h5tn5P+4sytX8hF+zRnq 7k896TWSmH3FY9k5aBgAwJogMrbQWpZsQCUmYUTo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pradeep Kumar Chitrapu , Kalle Valo , Sasha Levin Subject: [PATCH 5.10 011/289] ath11k: fix thermal temperature read Date: Mon, 17 May 2021 15:58:56 +0200 Message-Id: <20210517140305.562268058@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pradeep Kumar Chitrapu [ Upstream commit e3de5bb7ac1a4cb262f8768924fd3ef6182b10bb ] Fix dangling pointer in thermal temperature event which causes incorrect temperature read. Tested-on: IPQ8074 AHB WLAN.HK.2.4.0.1-00041-QCAHKSWPL_SILICONZ-1 Signed-off-by: Pradeep Kumar Chitrapu Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20210218182708.8844-1-pradeepc@codeaurora.org Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/ath11k/wmi.c | 53 +++++++++++---------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index 173ab6ceed1f..eca86225a341 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -4986,31 +4986,6 @@ int ath11k_wmi_pull_fw_stats(struct ath11k_base *ab, struct sk_buff *skb, return 0; } -static int -ath11k_pull_pdev_temp_ev(struct ath11k_base *ab, u8 *evt_buf, - u32 len, const struct wmi_pdev_temperature_event *ev) -{ - const void **tb; - int ret; - - tb = ath11k_wmi_tlv_parse_alloc(ab, evt_buf, len, GFP_ATOMIC); - if (IS_ERR(tb)) { - ret = PTR_ERR(tb); - ath11k_warn(ab, "failed to parse tlv: %d\n", ret); - return ret; - } - - ev = tb[WMI_TAG_PDEV_TEMPERATURE_EVENT]; - if (!ev) { - ath11k_warn(ab, "failed to fetch pdev temp ev"); - kfree(tb); - return -EPROTO; - } - - kfree(tb); - return 0; -} - size_t ath11k_wmi_fw_stats_num_vdevs(struct list_head *head) { struct ath11k_fw_stats_vdev *i; @@ -6390,23 +6365,37 @@ ath11k_wmi_pdev_temperature_event(struct ath11k_base *ab, struct sk_buff *skb) { struct ath11k *ar; - struct wmi_pdev_temperature_event ev = {0}; + const void **tb; + const struct wmi_pdev_temperature_event *ev; + int ret; + + tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); + if (IS_ERR(tb)) { + ret = PTR_ERR(tb); + ath11k_warn(ab, "failed to parse tlv: %d\n", ret); + return; + } - if (ath11k_pull_pdev_temp_ev(ab, skb->data, skb->len, &ev) != 0) { - ath11k_warn(ab, "failed to extract pdev temperature event"); + ev = tb[WMI_TAG_PDEV_TEMPERATURE_EVENT]; + if (!ev) { + ath11k_warn(ab, "failed to fetch pdev temp ev"); + kfree(tb); return; } ath11k_dbg(ab, ATH11K_DBG_WMI, - "pdev temperature ev temp %d pdev_id %d\n", ev.temp, ev.pdev_id); + "pdev temperature ev temp %d pdev_id %d\n", ev->temp, ev->pdev_id); - ar = ath11k_mac_get_ar_by_pdev_id(ab, ev.pdev_id); + ar = ath11k_mac_get_ar_by_pdev_id(ab, ev->pdev_id); if (!ar) { - ath11k_warn(ab, "invalid pdev id in pdev temperature ev %d", ev.pdev_id); + ath11k_warn(ab, "invalid pdev id in pdev temperature ev %d", ev->pdev_id); + kfree(tb); return; } - ath11k_thermal_event_temperature(ar, ev.temp); + ath11k_thermal_event_temperature(ar, ev->temp); + + kfree(tb); } static void ath11k_wmi_tlv_op_rx(struct ath11k_base *ab, struct sk_buff *skb) -- 2.30.2