Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6817229rwd; Tue, 6 Jun 2023 02:17:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ51vZuLOnL6IDMA9/aBlWl4veVML+n1e049CcMrktuyXmJ8QZUdwUSTmbGad5YIvYB1oUrQ X-Received: by 2002:a05:620a:2603:b0:75b:23a1:d8cb with SMTP id z3-20020a05620a260300b0075b23a1d8cbmr1776278qko.15.1686043025358; Tue, 06 Jun 2023 02:17:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686043025; cv=none; d=google.com; s=arc-20160816; b=tPnftiI+oqlxoPvcNOyomvXvwyiy3kkvqa3EEUs5uLfc6t5u9BZlZGXuuF0aI7t2e1 AzeUNIv19YTQPfjPF85+4k003Ox7Y0fwDSWN2epZ9HGmyhWoiZ9be3YFSzcZOz1C2jbq 1MOxwGoVP2SrNdyogOUawl1jw7SLFTJCpnJIN7b0QdrxWB9VjmfHcI5SA2NBQ1/luYeG PLCTX+B7lqrQ62jcEcAsLjngQBbdirccbtbowfmSp9sZZmiJlMdAO70dl2EOTzZkQYUA IWh1VbzD7YT7IEZPp+nnr5Nvjei9D2laegvx2qBe+PyKGRjcyHW2Z+HkC6NlGOUZ5qHB c+TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=Z739tshZdcCOSCVWX/c0g3mPD4OKB+kCcIYxzcUC5pw=; b=OYKBXzOHJuTddTvbmrH0uItleAdHrPkqu8hsQnDEAoN36dbIXlizLUTIVDGxB+kipg s3FU+aeDBdBtSBW/gNcijupFEpI5wys5tG69ED6MJ4fdc43Te8wlg5Ta6wUJ2FGP0Yrc aqODbd20hDFKJZzAiUnOk5ET8CCm2beQ8ZxjB8TEeKsa+mjKngl56MM2/VV5WKdNn8V2 18q5BH6Zx8RqdgQDVyaO2wjtvlIFLwuGkDjELJP9u7KCPXCr4Y2shbeyuruxiTpnNEFU JxVDmSyfPrtBvGfWShUyPAxZUjjyapbzQSBEzmIWXw90fEnYPgOL/ARAwjbAKKt4MW52 IpFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=EoAr5ruO; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j4-20020a37c244000000b0075afaac62e8si74824qkm.131.2023.06.06.02.16.56; Tue, 06 Jun 2023 02:17:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=EoAr5ruO; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230080AbjFFJL6 (ORCPT + 62 others); Tue, 6 Jun 2023 05:11:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229913AbjFFJL5 (ORCPT ); Tue, 6 Jun 2023 05:11:57 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B2E2109 for ; Tue, 6 Jun 2023 02:11:56 -0700 (PDT) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3565lJaZ023783; Tue, 6 Jun 2023 09:11:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=qcppdkim1; bh=Z739tshZdcCOSCVWX/c0g3mPD4OKB+kCcIYxzcUC5pw=; b=EoAr5ruOgVOLMD8VgwsOUhKubvfvCJmAA3Xy1541Bq09FR3KsSK8iZg61DPuUEgFv+0h tZefNPy0iGshV8QdWOa0e1asj/V93jPG1pQX4ViYTksU6iQR15GWhcwv++IJe5VpJcws bgXfimiouFW0kwAxDHNhoStXXVtPJqPQZEeKtMtYI9OPd6KwGGnk1Y8gBJv/yAhA0VKh S4JUNRkFjoh3YyBg6EUjSBvJ5h594DX0KmStmKx9ZxRT/lX+B5mwxkuR1G++nGWGlJx4 KEIYSeLKuMqmVmb5czFaRxI4gSJeYzn4VlY2hk8ASu035GUUrgXWjq672hJoVuhOdZtV dQ== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3r1xxr0dxj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Jun 2023 09:11:50 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3569BnJO030055 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 6 Jun 2023 09:11:49 GMT Received: from adisi-linux.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Tue, 6 Jun 2023 02:11:46 -0700 From: Aditya Kumar Singh To: CC: , P Praneesh , Aditya Kumar Singh Subject: [PATCH] wifi: ath11k: fix memory leak in WMI firmware stats Date: Tue, 6 Jun 2023 14:41:28 +0530 Message-ID: <20230606091128.14202-1-quic_adisi@quicinc.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: YLa51FTN1lJxfko8yUPqCEOqx6VgCWcg X-Proofpoint-ORIG-GUID: YLa51FTN1lJxfko8yUPqCEOqx6VgCWcg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_05,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 lowpriorityscore=0 suspectscore=0 phishscore=0 impostorscore=0 mlxlogscore=939 spamscore=0 mlxscore=0 adultscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060078 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: P Praneesh Memory allocated for firmware pdev, vdev and beacon statistics are not released during rmmod. Fix it by calling ath11k_fw_stats_free() function before hardware unregister. While at it, avoid calling ath11k_fw_stats_free() while processing the firmware stats received in the WMI event because the local list is getting spliced and reinitialised and hence there are no elements in the list after splicing. Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 Signed-off-by: P Praneesh Signed-off-by: Aditya Kumar Singh --- drivers/net/wireless/ath/ath11k/mac.c | 1 + drivers/net/wireless/ath/ath11k/wmi.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index a31b8e89684b..2e462e7a8b4d 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -9792,6 +9792,7 @@ void ath11k_mac_destroy(struct ath11k_base *ab) if (!ar) continue; + ath11k_fw_stats_free(&ar->fw_stats); ieee80211_free_hw(ar->hw); pdev->ar = NULL; } diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index 68622a850527..8b457558b975 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -8097,6 +8097,11 @@ static void ath11k_update_stats_event(struct ath11k_base *ab, struct sk_buff *sk rcu_read_unlock(); spin_unlock_bh(&ar->data_lock); + /* Since the stats's pdev, vdev and beacon list are spliced and reinitialised + * at this point, no need to free the individual list. + */ + return; + free: ath11k_fw_stats_free(&stats); } base-commit: a4756ac34a7002861c9bdf8cf45aec53a77fb78d -- 2.17.1