Received: by 10.213.65.68 with SMTP id h4csp276774imn; Fri, 23 Mar 2018 04:32:47 -0700 (PDT) X-Google-Smtp-Source: AG47ELszGn5nuV69Ujh8nJxShI9kfmqSUatd0FJ7vT0p7OWoi7FA7IepjAoHrAXYyYOIYn0QoD4l X-Received: by 10.98.224.93 with SMTP id f90mr12362944pfh.21.1521804767437; Fri, 23 Mar 2018 04:32:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521804767; cv=none; d=google.com; s=arc-20160816; b=AeP7fQToM187Kx2iW5fF1xR8DMJsVKotDJ2fpR7AfJTamsl8ZukbZH7Zkp8TZkrKG7 NlcjTYI67XvxnN9b6eobMS/Rv89+CoI7oPHHwyYTaGuPEQLgGjGaMcG5xB7Y+5UJcEVt Z4pz1tO3ruX26C8W0Z2sA1qgVM63U6KzukJSAlqjnmGmS15YkM31iRycajqhznT6NS95 Z/ZnpGs6WipLyVCeA0Ej1z3wv5DAthCQTw48Stc5zzNEMVn0G2yYvbkmLngiG83Jwvz7 1OGrjyp80U3siQW2rpnw8vJn/Dgteb5SmnRmiERDGrb3v44NxvQOJBc3VKJ+4/Q2Lkt0 lyQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=KdryLDj591OeTc6qHupJ7VpmEczC9lRsauaCOkrMPvw=; b=aWMDPnVOn3pvsXg/KpuMBoWUGOT5SOGnuzqyn9+Zkh4NSbT/rtW6BoJN9IJGV1jphs uCS4nsZytwj/zqP2urHQly3rkT+fRpmyrBPP3CEn+ckEBRxrbpg4pQ2zZ21FosHTEtcI uZZUmvWqoTV6bwrcOTmd+Vbs+w67WU5QqqbZ3oLBltPO+f8XeP/42FJC4tB9mRJu37my CsqmYhw+1dhfMt2SEmxUZkwnLjiyPcy2jQCQQ4+TXjOxOKDVgiYngUouDG2cNMyljsf/ OtzZZtEhrqNu58V4CopKVSPgo51cIwPvbEBtgOxP54t/8KWlXokUVxHY07VvKnpoCsQe ta6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k5si6021246pgr.143.2018.03.23.04.32.33; Fri, 23 Mar 2018 04:32:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755178AbeCWKGJ (ORCPT + 99 others); Fri, 23 Mar 2018 06:06:09 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40640 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755146AbeCWKGA (ORCPT ); Fri, 23 Mar 2018 06:06:00 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BA84629; Fri, 23 Mar 2018 10:05:59 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brian Norris , Kalle Valo , Sasha Levin Subject: [PATCH 4.9 034/177] mwifiex: dont leak chan_stats on reset Date: Fri, 23 Mar 2018 10:52:42 +0100 Message-Id: <20180323094206.669962569@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094205.090519271@linuxfoundation.org> References: <20180323094205.090519271@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Brian Norris [ Upstream commit fb9e67bee3ab7111513130c516ffe378d885c0d0 ] '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 Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/marvell/mwifiex/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/net/wireless/marvell/mwifiex/main.c +++ b/drivers/net/wireless/marvell/mwifiex/main.c @@ -146,7 +146,6 @@ static int mwifiex_unregister(struct mwi kfree(adapter->regd); - vfree(adapter->chan_stats); kfree(adapter); return 0; } @@ -636,6 +635,7 @@ static void mwifiex_fw_dpc(const struct goto done; err_add_intf: + vfree(adapter->chan_stats); wiphy_unregister(adapter->wiphy); wiphy_free(adapter->wiphy); err_init_fw: @@ -1429,6 +1429,7 @@ mwifiex_shutdown_sw(struct mwifiex_adapt mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev); rtnl_unlock(); } + vfree(adapter->chan_stats); up(sem); exit_sem_err: @@ -1729,6 +1730,7 @@ int mwifiex_remove_card(struct mwifiex_a mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev); rtnl_unlock(); } + vfree(adapter->chan_stats); wiphy_unregister(adapter->wiphy); wiphy_free(adapter->wiphy);