From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753338AbcIOR2P (ORCPT ); Thu, 15 Sep 2016 13:28:15 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:48168 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751754AbcIOR2H (ORCPT ); Thu, 15 Sep 2016 13:28:07 -0400 Subject: Re: [PATCH] mwifiex: fix memory leak on regd when chan is zero To: Kalle Valo References: <20160915162117.1209-1-colin.king@canonical.com> <87vaxx9jhk.fsf@kamboji.qca.qualcomm.com> Cc: Amitkumar Karwar , Nishant Sarmukadam , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org From: Colin Ian King Message-ID: <6afd51c2-c603-c887-3d75-3a1775bfe11c@canonical.com> Date: Thu, 15 Sep 2016 18:26:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <87vaxx9jhk.fsf@kamboji.qca.qualcomm.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15/09/16 18:10, Kalle Valo wrote: > Colin King writes: > >> From: Colin Ian King >> >> When chan is zero mwifiex_create_custom_regdomain does not kfree >> regd and we have a memory leak. Fix this by freeing regd before >> the return. >> >> Signed-off-by: Colin Ian King >> --- >> drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c >> index 3344a26..15a91f3 100644 >> --- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c >> +++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c >> @@ -1049,8 +1049,10 @@ mwifiex_create_custom_regdomain(struct mwifiex_private *priv, >> enum nl80211_band band; >> >> chan = *buf++; >> - if (!chan) >> + if (!chan) { >> + kfree(regd); >> return NULL; >> + } > > Bob sent a similar fix and he also did more: > > mwifiex: fix error handling in mwifiex_create_custom_regdomain > > https://patchwork.kernel.org/patch/9331337/ > Ah, sorry for the duplication noise. Colin