Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7470979pxb; Thu, 18 Feb 2021 10:53:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJyVzARlKd2ZL5eoLGovRYkAOJqSUuQfm9/TK1o9Fav1ydrNFhQ2bU03qjUY/iVn5P5gJbgE X-Received: by 2002:a05:6402:1155:: with SMTP id g21mr5409452edw.279.1613674386477; Thu, 18 Feb 2021 10:53:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613674386; cv=none; d=google.com; s=arc-20160816; b=wEkxm1nCxH8fRMEuQoT9sNeQIMqxYuYL2P9zyiCIDPb2LB+5et2N0zeJ+b2wwVU1GU k+HUhAXeB4d4CvUw8+k60ENP9bCa812978On4dqDIf/3nIptCIm6St+gP3IseaHLB5ly jGw0lTxNOprc8L+lxxfYQA6GWqaMtfWCRRWrjLXgLPI413B7Hi0e1mguMt9InkBVnwcf P7TY0SyzylJw+8OR1Bj/bYMEu41Sb5zntGEK5iRcdy7uaRRxatw6JqX9rtfNqfR0yQyd Tophk4tffGnOmbHw6Yvg5Gg5YEwcwrrcR/vyivOBhBQ5j/JF2QZOAYfW62xYugNP0C+t Y7UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:dmarc-filter :sender:dkim-signature; bh=JNThsiI+WhFDxXYq8dUMlqi3X/vhOrdr+SHYcPBEDJQ=; b=q8h94c1RTV8o+Jz5MInNQBNIIPLZN6DEkrtZB4jsWrMOPAnGs2F8zP0VFscSB4zbdx MvaL2LO55ty3NZftLjcIyTxAvyNNgHUh2XnvdZSm+atAixXNv6TGwDqYAb4bBdHGUYX5 uQyr9ch8ZRaADzh2fmPOlzNEXqztF0yv7HA5cikQwnjfrkOIr0JNWjx/FHPPiu3dauBq 55LSZrVIpLyj39OStTHdEUkQQGnji3lifkwxOykD9fntKPWU4ng6HPkZHHQzsMIMoR+P z7QFxXnXamSPh2SJ1TbP8TRv3umSvXGiIWQu+OstughTi30VJjrG1XsWqSuIFEhJp8Jg YEoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=vhwxmB8j; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id js1si3789376ejc.662.2021.02.18.10.52.34; Thu, 18 Feb 2021 10:53:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-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=@mg.codeaurora.org header.s=smtp header.b=vhwxmB8j; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232904AbhBRSv1 (ORCPT + 99 others); Thu, 18 Feb 2021 13:51:27 -0500 Received: from m42-2.mailgun.net ([69.72.42.2]:43011 "EHLO m42-2.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231965AbhBRS2Z (ORCPT ); Thu, 18 Feb 2021 13:28:25 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1613672870; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=JNThsiI+WhFDxXYq8dUMlqi3X/vhOrdr+SHYcPBEDJQ=; b=vhwxmB8juS5JklggQVDj4FI+ODWbwt4kxJZdibOV/ShIq2mqkpYM9VPcY5131zu+9FaysoLk Hhr+IuAfTeRHcezOxDxq9EzLeE3Z6PGSgO85L/uxD4CcCgIcC6CrRfhmR8UoUh4nDdGKPjKB hj3jj5xXPO4tg0Otf6+AKQe8DHY= X-Mailgun-Sending-Ip: 69.72.42.2 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-east-1.postgun.com with SMTP id 602eb1873bd0a42cc929a021 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 18 Feb 2021 18:27:19 GMT Sender: pradeepc=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id CF05CC433CA; Thu, 18 Feb 2021 18:27:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from pradeepc2-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pradeepc) by smtp.codeaurora.org (Postfix) with ESMTPSA id D7B61C433C6; Thu, 18 Feb 2021 18:27:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D7B61C433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=pradeepc@codeaurora.org From: Pradeep Kumar Chitrapu To: ath11k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Pradeep Kumar Chitrapu Subject: [PATCH V2] ath11k: fix thermal temperature read Date: Thu, 18 Feb 2021 10:27:08 -0800 Message-Id: <20210218182708.8844-1-pradeepc@codeaurora.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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 --- v2: rebased 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 cccfd3bd4d27..ca5cda890d58 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -5417,31 +5417,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; @@ -6849,23 +6824,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_fils_discovery_event(struct ath11k_base *ab, -- 2.17.1