From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754904AbcIOQXW (ORCPT ); Thu, 15 Sep 2016 12:23:22 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:47516 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754253AbcIOQXL (ORCPT ); Thu, 15 Sep 2016 12:23:11 -0400 From: Colin King To: Amitkumar Karwar , Nishant Sarmukadam , Kalle Valo , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] mwifiex: fix memory leak on regd when chan is zero Date: Thu, 15 Sep 2016 17:21:17 +0100 Message-Id: <20160915162117.1209-1-colin.king@canonical.com> X-Mailer: git-send-email 2.9.3 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; + } chflags = *buf++; band = (chan <= 14) ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ; freq = ieee80211_channel_to_frequency(chan, band); -- 2.9.3