Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp691823pxx; Wed, 28 Oct 2020 14:39:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjJBcAcvS+2IvkE1Pc7wLGrCnX5s4nGKP16bnDoxXwn5lWTDi/2KlXLm8biQPfrKLEdgoM X-Received: by 2002:a17:906:4803:: with SMTP id w3mr1060711ejq.406.1603921169977; Wed, 28 Oct 2020 14:39:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603921169; cv=none; d=google.com; s=arc-20160816; b=Ff/hOe6S8/+k9s9v3hzEYYSeFwxSIT6VzcfFNcdB8wZ6/XvuwW4Z3HmDDNodxYPNSy 2RI9AZKS67K2DkSV60B3D1XLCDzLKKwqnzAhNEGNZTx2BbrXHpGlyf5ICbWRYWZocrVi fdyq+h9Poz0Xnw1oIkCWyorL+De7A35KhDnmShL6rSTYEmdEZ5C//Jkj1K/wtf3dGZJq yKwxj8GujWvFJ0LVsBr8lktMRmP/N56QBLno8MR1JSxpyDBSeZjJ59+au+6DlBlzWWt8 iM9N067oWhIlJbKogdEipbE9HK9apYtATAMa5dR8kD9iBZcd6XYHsrTY7PXWPk2UalYd 38Ug== 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=sZ91uehuVZd74XI9lyDbkGITZ2i0dTuN780qR1MBdII=; b=aFiJU0pMQ0R314OWek6zUlljzSVe+/MXWJxn1j5BC2suoapNrmZwl4hLeWmfpQ2IhZ h+kMnQ2ExSipuoObI4WsT1QAF9yTsBtWtQa1rdrV9Ve7LTu8OP/b2Vs41PIwEEKu9fmj JPXevIKss68iDechRKpYzkUov7d85M7X/P17+49ojWcc6MY3VA5xBZNhDGMT+e2KCMPL dHCTQE3vpkG93MeIEOL6Fsy/DM3AFTiDTGotEBYw/IYF9CZWB+y2OmoEiCFgYl/X2ry3 IJLh2UmmhOjyRymJoP/fEAtc2AzQ1gx2OAGi0otOyZ1g+jhcQ+N6Da+hCh80+i+Z2DMz Ko4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=MvLaZnZy; 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 k9si575376edf.377.2020.10.28.14.38.51; Wed, 28 Oct 2020 14:39:29 -0700 (PDT) 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=MvLaZnZy; 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 S1832119AbgJ0VLe (ORCPT + 99 others); Tue, 27 Oct 2020 17:11:34 -0400 Received: from m42-4.mailgun.net ([69.72.42.4]:64862 "EHLO m42-4.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2505416AbgJ0VLe (ORCPT ); Tue, 27 Oct 2020 17:11:34 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1603833093; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=sZ91uehuVZd74XI9lyDbkGITZ2i0dTuN780qR1MBdII=; b=MvLaZnZyuEJKG0xCJ/36f9T+BLzi+AY34yFjEETVjeoVdUnnKn+K4GmwTUQjaQlO0+FymDKf 9NFMONOipJ2rYVBud2Z8Dp7NDNDtboOkksbyb/zLBx3Iq+9elnjJfk7d+15w+MK3moLWFJ7n TKhQDU1+nVdIDh6JLxYW9nP2uac= X-Mailgun-Sending-Ip: 69.72.42.4 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-n04.prod.us-east-1.postgun.com with SMTP id 5f9887896ce3c4dc2e37506a (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 27 Oct 2020 20:48:09 GMT Sender: pradeepc=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 8424AC433F0; Tue, 27 Oct 2020 20:48:08 +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 CFE3BC433CB; Tue, 27 Oct 2020 20:48:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org CFE3BC433CB 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] ath11k: fix thermal temperature read Date: Tue, 27 Oct 2020 13:48:03 -0700 Message-Id: <20201027204803.12464-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 --- 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 8eca92520837..0008df7458e7 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -5017,31 +5017,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; @@ -6410,23 +6385,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) base-commit: 3cb12d27ff655e57e8efe3486dca2a22f4e30578 -- 2.17.1