From patchwork Tue Jul 12 11:43:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: weiyj_lk@163.com X-Patchwork-Id: 9225159 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 1605060572 for ; Tue, 12 Jul 2016 11:43:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 063472787D for ; Tue, 12 Jul 2016 11:43:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE63527E63; Tue, 12 Jul 2016 11:43:34 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham 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 6FFC02787D for ; Tue, 12 Jul 2016 11:43:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933126AbcGLLnc (ORCPT ); Tue, 12 Jul 2016 07:43:32 -0400 Received: from m12-18.163.com ([220.181.12.18]:38177 "EHLO m12-18.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932915AbcGLLnb (ORCPT ); Tue, 12 Jul 2016 07:43:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=8jbys VCEjUIzErxYg/+xVDxr9NV8LlJ0Qg+s0+3OaXE=; b=DPeytN4dunhTlVjECRqTU a/bGwPB5QTlBZfMF4PcznBLWqZA2z+KsEYbReWDUTBQfe1xKabcy5lP+RERHmf03 cYgMIAc7BBvvNSV2jUMXuAOCKd6T499bK3wiH4rHTFoamarxjj4pTJ7BpxtuWRz8 bCMDj7Jh5qB3cFpZUTEjcw= Received: from localhost.localdomain.localdomain (unknown [180.110.253.144]) by smtp14 (Coremail) with SMTP id EsCowABH1RzW14RXhCCABQ--.42109S2; Tue, 12 Jul 2016 19:43:20 +0800 (CST) From: weiyj_lk@163.com To: Amitkumar Karwar , Nishant Sarmukadam , Kalle Valo Cc: Wei Yongjun , linux-wireless@vger.kernel.org Subject: [PATCH -next] mwifiex: fix possible memory leak in mwifiex_cfg80211_start_ap() Date: Tue, 12 Jul 2016 11:43:18 +0000 Message-Id: <1468323798-6075-1-git-send-email-weiyj_lk@163.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-CM-TRANSID: EsCowABH1RzW14RXhCCABQ--.42109S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxJF1ruF43Zw15CF48KFykXwb_yoW8ZrWDpw sxXr9Yqr10yw1Yywn5JF4UZas09a18KFy7uFySyw4rCF1jyr1rZr1jkFy8Kry8Ja92gw1a k3WvvF15Ga97ArDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jD2-5UUUUU= X-Originating-IP: [180.110.253.144] X-CM-SenderInfo: pzhl5yxbonqiywtou0bp/1tbiGQqk1lXlT1FDtgABs7 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 From: Wei Yongjun memory is malloced in mwifiex_cfg80211_start_ap() and should be freed before leaving from the error handling cases, otherwise it will cause memory leak. Signed-off-by: Wei Yongjun --- drivers/net/wireless/marvell/mwifiex/cfg80211.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c index df5ebdf..1eec77e 100644 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c @@ -1936,10 +1936,9 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy, mwifiex_set_uap_rates(bss_cfg, params); if (mwifiex_set_secure_params(priv, bss_cfg, params)) { - kfree(bss_cfg); mwifiex_dbg(priv->adapter, ERROR, "Failed to parse secuirty parameters!\n"); - return -1; + goto out; } mwifiex_set_ht_params(priv, bss_cfg, params); @@ -1968,7 +1967,7 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy, if (mwifiex_11h_activate(priv, false)) { mwifiex_dbg(priv->adapter, ERROR, "Failed to disable 11h extensions!!"); - return -1; + goto out; } priv->state_11h.is_11h_active = false; } @@ -1976,12 +1975,11 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy, if (mwifiex_config_start_uap(priv, bss_cfg)) { mwifiex_dbg(priv->adapter, ERROR, "Failed to start AP\n"); - kfree(bss_cfg); - return -1; + goto out; } if (mwifiex_set_mgmt_ies(priv, ¶ms->beacon)) - return -1; + goto out; if (!netif_carrier_ok(priv->netdev)) netif_carrier_on(priv->netdev); @@ -1990,6 +1988,10 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy, memcpy(&priv->bss_cfg, bss_cfg, sizeof(priv->bss_cfg)); kfree(bss_cfg); return 0; + +out: + kfree(bss_cfg); + return -1; } /*