From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8B5FC072B1 for ; Thu, 30 May 2019 04:24:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9235D253AF for ; Thu, 30 May 2019 04:24:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559190279; bh=2EzRCk6ucJaYzo9xlbwg+bpp8Agv2zet2GiQ6f0xZNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=2OX15KOrLl4JxnqwAJGInfAzAGcENSdrtPrgGXpcLoMahhsx5ahB059Vd9I8977tk RmZypjO7i1brDvU9pITPBwlSrvNSKN0h55TqU50ZNoCLaQWJzSvePll7Z0FX9LL6A3 941+vJoQIKU/gzw5N6n9iDQs+Bzs2NJ9dui9XNlI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730134AbfE3EYX (ORCPT ); Thu, 30 May 2019 00:24:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:36218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730030AbfE3DOw (ORCPT ); Wed, 29 May 2019 23:14:52 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 336EA245A4; Thu, 30 May 2019 03:14:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186092; bh=2EzRCk6ucJaYzo9xlbwg+bpp8Agv2zet2GiQ6f0xZNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0XthtUZPC+4J4s230pZohrCb6FmhppeTwHpooyE/YPANU9V93hn8HXzad8ksvrnQX FZo2jVSKCHqoxGNomiALHfZ1Y23yq5wkxP2ALhvbraVchkCgmdQY84fO5R+d7sKowK 9bg3OsXbRhl/WIZ0TzFtcsyZCQMYsKAh154/JV98= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, YueHaibing , Kalle Valo , Sasha Levin Subject: [PATCH 5.0 224/346] mwifiex: Fix mem leak in mwifiex_tm_cmd Date: Wed, 29 May 2019 20:04:57 -0700 Message-Id: <20190530030552.425344820@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030540.363386121@linuxfoundation.org> References: <20190530030540.363386121@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org [ Upstream commit 003b686ace820ce2d635a83f10f2d7f9c147dabc ] 'hostcmd' is alloced by kzalloc, should be freed before leaving from the error handling cases, otherwise it will cause mem leak. Fixes: 3935ccc14d2c ("mwifiex: add cfg80211 testmode support") Signed-off-by: YueHaibing Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin --- drivers/net/wireless/marvell/mwifiex/cfg80211.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c index 883752f640b41..4bc25dc5dc1d5 100644 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c @@ -4073,16 +4073,20 @@ static int mwifiex_tm_cmd(struct wiphy *wiphy, struct wireless_dev *wdev, if (mwifiex_send_cmd(priv, 0, 0, 0, hostcmd, true)) { dev_err(priv->adapter->dev, "Failed to process hostcmd\n"); + kfree(hostcmd); return -EFAULT; } /* process hostcmd response*/ skb = cfg80211_testmode_alloc_reply_skb(wiphy, hostcmd->len); - if (!skb) + if (!skb) { + kfree(hostcmd); return -ENOMEM; + } err = nla_put(skb, MWIFIEX_TM_ATTR_DATA, hostcmd->len, hostcmd->cmd); if (err) { + kfree(hostcmd); kfree_skb(skb); return -EMSGSIZE; } -- 2.20.1