From patchwork Fri Apr 14 21:51:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 9681821 X-Patchwork-Delegate: kvalo@adurom.com 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 E20DC60386 for ; Fri, 14 Apr 2017 21:52:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3A0C283FB for ; Fri, 14 Apr 2017 21:52:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8320285B9; Fri, 14 Apr 2017 21:52:36 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFC7828569 for ; Fri, 14 Apr 2017 21:52:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755466AbdDNVwW (ORCPT ); Fri, 14 Apr 2017 17:52:22 -0400 Received: from mail-pg0-f53.google.com ([74.125.83.53]:34619 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755186AbdDNVvt (ORCPT ); Fri, 14 Apr 2017 17:51:49 -0400 Received: by mail-pg0-f53.google.com with SMTP id 21so47981793pgg.1 for ; Fri, 14 Apr 2017 14:51:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GBN8Yb43OXqZoc/fwOXH7UoQTL1amwbWXT9A3DNSAPo=; b=az/rXSOB5iqGxbMnweLV9SaJJtfzVP3jc8coGWjyIQPW+fkrKKz08thciKU4ibfdms o5SbNG+gwY/vnhSNPgJTFBtsp35R+HPDKq9N2VFFDsO9KLuUyyYQ+Nr7V6O2rTvK+3+F ChBRxg6sDarEOkz7WDw1Ae7e675IFQwOE3bKk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GBN8Yb43OXqZoc/fwOXH7UoQTL1amwbWXT9A3DNSAPo=; b=L7LZkcR66aUOLvPCp5Hw7TjJq4mu5kia0EpbVwtM55qJCOz1ZYazVLUWoRQTbOtFkf r13AYbw4Onz2WIVsxicXFLxsgNHqzyxAwcTYQ4euxIyMxBd/e86z0W9zwLaZ35m3om5f mbgywqnomb/awPSi1viGztdiVmD3kuq6QcwcEDpTbvwQNm75+sNNpw3BkpTrTV0I4DB8 MKCw9YgPHUYPVnv6EbrVnTiAKoJ1NTe/GiJNcm2Uc+XGMwMpu9boNAFCe4UlHEPna5PH yNZ/0tYLaBKlHJK4dDyjZZaGM6WfvOy/1s95k3UhPNWCK/VUJrrNT0+TXsnA+XUSlQ5T lcvQ== X-Gm-Message-State: AN3rC/49bVcRAevTOMKpgKIHi86p62ukvu8aUqVM6njoYQgawqgR2tCZ q4ZPpE85G6AgBinX X-Received: by 10.98.86.75 with SMTP id k72mr4471246pfb.215.1492206709270; Fri, 14 Apr 2017 14:51:49 -0700 (PDT) Received: from ban.mtv.corp.google.com ([172.22.64.120]) by smtp.gmail.com with ESMTPSA id n85sm4879081pfi.101.2017.04.14.14.51.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Apr 2017 14:51:48 -0700 (PDT) From: Brian Norris To: Ganapathi Bhat , Nishant Sarmukadam Cc: , Dmitry Torokhov , Kalle Valo , linux-wireless@vger.kernel.org, Brian Norris Subject: [PATCH 4/4] mwifiex: don't leak 'chan_stats' on reset Date: Fri, 14 Apr 2017 14:51:20 -0700 Message-Id: <20170414215120.145038-4-briannorris@chromium.org> X-Mailer: git-send-email 2.12.2.762.g0e3151a226-goog In-Reply-To: <20170414215120.145038-1-briannorris@chromium.org> References: <20170414215120.145038-1-briannorris@chromium.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 'chan_stats' is (re)allocated in _mwifiex_fw_dpc() -> mwifiex_init_channel_scan_gap(), which is called whenever the device is initialized -- at probe or at reset. But we only free it in we completely unregister the adapter, meaning we leak a copy of it during every reset. Let's free it in the shutdown / removal paths instead (and in the error-handling path), to avoid the leak. Ideally, we can eventually unify much of mwifiex_shutdown_sw() and mwifiex_remove_card() (way too much copy-and-paste) to reduce the burden on bugfixes like this. But that's work for tomorrow. Signed-off-by: Brian Norris --- Technically a bugfix, but I don't know where to "blame" it. drivers/net/wireless/marvell/mwifiex/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c index 89eccd7adbe5..31fa62c4c148 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.c +++ b/drivers/net/wireless/marvell/mwifiex/main.c @@ -149,7 +149,6 @@ static int mwifiex_unregister(struct mwifiex_adapter *adapter) kfree(adapter->regd); - vfree(adapter->chan_stats); kfree(adapter); return 0; } @@ -633,6 +632,7 @@ static int _mwifiex_fw_dpc(const struct firmware *firmware, void *context) goto done; err_add_intf: + vfree(adapter->chan_stats); wiphy_unregister(adapter->wiphy); wiphy_free(adapter->wiphy); err_init_fw: @@ -1417,6 +1417,7 @@ mwifiex_shutdown_sw(struct mwifiex_adapter *adapter) mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev); rtnl_unlock(); } + vfree(adapter->chan_stats); mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__); exit_return: @@ -1728,6 +1729,7 @@ int mwifiex_remove_card(struct mwifiex_adapter *adapter) mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev); rtnl_unlock(); } + vfree(adapter->chan_stats); wiphy_unregister(adapter->wiphy); wiphy_free(adapter->wiphy);