Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp250322ybi; Wed, 29 May 2019 20:38:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2QTwKAO0GC7EYCGEXDJSKmC8CRd2rKKvvLzX9+Evg0fAIJzdpKU5cjcgh9qaqWBIh2zKc X-Received: by 2002:a17:90a:9503:: with SMTP id t3mr1442490pjo.47.1559187538396; Wed, 29 May 2019 20:38:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559187538; cv=none; d=google.com; s=arc-20160816; b=GgzyiiV+88TnIlLh+sXqVsGk9WnYmx0P0YlvFjHnbWae0GOvC5RirPQe+ybEMvKPOD Esg8Vy2OwcKh1o/kVCJAPJ27ds5r7bKRVseC9c8waUycWuYHYRNqW1nHGYojmC3Z9c+q uFmHj7UK1DaPmCBCByPzeL/kJIvDmIRz7YbP0VGRA3LdcRflGC0gYwGJQe7BTu8Ib+IV Z9LAUzlwWx6rwIZzVYBv29t87GUPkn9hwjAL5d9R2G7OV/zX5LsI9pJXz5/RL04heg06 xutUuaUjI023Lxninv1AjT6nEP5xrF227xoTtIY8Xpigi116bdkzSkd0B5fljGJmLY09 N1/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aq9RkYlGEMRVQJkaoLGWn0VPH1O2McXE/M4qj0x6gOA=; b=Pn/tmCQxfz8HxyI9k2UCbZB25d9FGDVt7MVEys5VkkMx0qsA2ph1ZSK9wm5BZUANKy saRb3UX1l+QuIvP/ZiQGX2duFodiJfpTT5xvVoCKqVcSi4hi3mdWFfyjnVCRMR0euCqh 7DqTmh5d3D+hhHHFLfx9PfGF9dnUf1qAcWXwTMHNGN2dDILJm/j5ypifr7oFobocEtPb eCfZt8Zc3BjXQLbAupJDoy8ibVkbhcu0+7y3TXgbVLa9t57ODmCwNC5w6mckTRB2SpwP KiNOcuyLClfWlfD2YOGKoZLJRyVa0UU/E1En8J6FXJYVDalMyuK0+OMkO/YY4t/EHL9w phVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=x3ssG0s0; 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 i18si2195872pfd.64.2019.05.29.20.38.41; Wed, 29 May 2019 20:38:58 -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; dkim=pass header.i=@kernel.org header.s=default header.b=x3ssG0s0; 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 S1733149AbfE3DXt (ORCPT + 99 others); Wed, 29 May 2019 23:23:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:48146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731202AbfE3DRk (ORCPT ); Wed, 29 May 2019 23:17:40 -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 AB522245D7; Thu, 30 May 2019 03:17:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186259; bh=Cu5HcXtfpOXX1SPNQ97FVBeMtj3UnXi78tznb/syzG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x3ssG0s0vYuqxnXuioLrCEDRPD/O5ojj3O6qrw6ULWkXHdIOGH26anOWI/lnAoGRR fgp+JXPmc2Rmpcw/DGsmYHRq/2ibRU2DvcfXdpWCv3MWnkNJl1FJdL8U7Slk9lYTUq GfjaVgxpBslwFbAfJox52qnx0a6XzGXtwq39KSik= 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 4.19 192/276] mwifiex: Fix mem leak in mwifiex_tm_cmd Date: Wed, 29 May 2019 20:05:50 -0700 Message-Id: <20190530030537.167162805@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 2d87ebbfa4dab..47ec5293c045d 100644 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c @@ -4045,16 +4045,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