From patchwork Wed Aug 2 10:33:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Pillai X-Patchwork-Id: 9876601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9D56A60390 for ; Wed, 2 Aug 2017 10:34:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 978F12873E for ; Wed, 2 Aug 2017 10:34:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C4042879F; Wed, 2 Aug 2017 10:34:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9BE842873E for ; Wed, 2 Aug 2017 10:34:45 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=mKdzY4xUrNPIBqo1j+kyE9qbcvZqb0y6+zcdEIFLRWE=; b=org Q+0o2M45s6w8twEo3cV9aunrzojclDGWNTKv8wh9RHEhaW8IePD5TE7A+NFcmpC1NoTAzemmy9mqc DVfXY7ECo1zbWj51dyl1yAzdfupGHMWV51uhDpu8vcXSKDYMQWJwE3LOv7squr3bJcTO4EJguZq9D UFsrL2+eSN/yKUSwCtD6G/9jtRo2dACV9GO61HjJ07YkdSRDsHDITBayl9+unrY9zn6rM3jVccnFH BoXMhuHMnF0hXUxZ4hghV946KO5cU9qH9A+J+YxpPH5r9PHNhFDQ/L7qxEQcdLx0o33Qd5ab7LGtE eXgJ3Twtq659eXP1NxD/muTubzJWhVQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dcqyy-0003T8-Kx; Wed, 02 Aug 2017 10:34:28 +0000 Received: from sabertooth01.qualcomm.com ([65.197.215.72]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dcqym-0003O0-Sn for ath10k@lists.infradead.org; Wed, 02 Aug 2017 10:34:25 +0000 X-IronPort-AV: E=Sophos;i="5.41,310,1498546800"; d="scan'208";a="111939827" Received: from unknown (HELO Ironmsg03-L.qualcomm.com) ([10.53.140.110]) by sabertooth01.qualcomm.com with ESMTP; 02 Aug 2017 03:33:54 -0700 X-IronPort-AV: E=McAfee;i="5900,7806,8609"; a="1420653817" X-MGA-submission: =?us-ascii?q?MDGyjjSMfftlDCVKZ5dlrk4U1GhQAiC/Dv/xzb?= =?us-ascii?q?p+gZ/+AJf9ePALQAD3TAxfMNdOPWoiz7+TQp2QjRsL1MCeVlJ+CLYzgK?= =?us-ascii?q?EAMkcszRjDeDiXGZQURROIwAu0DMu6X0uSfWGKsBwm1XhNSUB3ZKbDyO?= =?us-ascii?q?oN?= Received: from pillair-linux.qualcomm.com ([10.204.116.193]) by Ironmsg03-L.qualcomm.com with ESMTP; 02 Aug 2017 03:33:53 -0700 Received: by pillair-linux.qualcomm.com (Postfix, from userid 452944) id AEAB61CFA; Wed, 2 Aug 2017 16:03:51 +0530 (IST) From: Rakesh Pillai To: ath10k@lists.infradead.org Subject: [PATCH v2] ath10k: fix memory leak in rx ring buffer allocation Date: Wed, 2 Aug 2017 16:03:37 +0530 Message-Id: <1501670017-12862-1-git-send-email-pillair@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170802_033417_026652_52FE9B8C X-CRM114-Status: UNSURE ( 8.89 ) X-CRM114-Notice: Please train this message. X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-wireless@vger.kernel.org, Rakesh Pillai MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rakesh Pillai ath10k: fix memory leak in rx ring buffer allocation The rx ring buffers are added to a hash table if firmware support full rx reorder. If the full rx reorder support flag is not set before allocating the rx ring buffers, none of the buffers are added to the hash table. There is a race condition between rx ring refill and rx buffer replenish from napi poll. The interrupts are enabled in hif start, before the rx ring is refilled during init. We replenish buffers from napi poll due to the interrupts which get enabled after hif start. Hence before the entire rx ring is refilled during the init, the napi poll replenishes a few buffers in steps of 100 buffers per attempt. During this rx ring replenish from napi poll, the rx reorder flag has not been set due to which the replenished buffers are not added to the hash table Set the rx full reorder support flag before we allocate the rx ring buffer to avoid the memory leak. Signed-off-by: Rakesh Pillai --- drivers/net/wireless/ath/ath10k/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index 6906bdd..10b3384 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -1886,6 +1886,12 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode, goto err_wmi_detach; } + /* If firmware indicates Full Rx Reorder support it must be used in a + * slightly different manner. Let HTT code know. + */ + ar->htt.rx_ring.in_ord_rx = !!(test_bit(WMI_SERVICE_RX_FULL_REORDER, + ar->wmi.svc_map)); + status = ath10k_htt_rx_alloc(&ar->htt); if (status) { ath10k_err(ar, "failed to alloc htt rx: %d\n", status); @@ -1997,12 +2003,6 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode, } } - /* If firmware indicates Full Rx Reorder support it must be used in a - * slightly different manner. Let HTT code know. - */ - ar->htt.rx_ring.in_ord_rx = !!(test_bit(WMI_SERVICE_RX_FULL_REORDER, - ar->wmi.svc_map)); - status = ath10k_htt_rx_ring_refill(ar); if (status) { ath10k_err(ar, "failed to refill htt rx ring: %d\n", status);