Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2293835pxb; Thu, 11 Feb 2021 08:51:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIF4M45HZWHOY/UZjyA4zJK7kDMSW538k2JfRGygD845NwgBFofg2g2xT7qW3fY3J9Sf4W X-Received: by 2002:a17:906:4c90:: with SMTP id q16mr9668921eju.49.1613062298583; Thu, 11 Feb 2021 08:51:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613062298; cv=none; d=google.com; s=arc-20160816; b=FATwQOVzpBenw/e6a9C0AgkR1IeNRBBNLapZATqahLI76JK2YeKfe+H7FBUCOId3Cz P99eOHGt+8N6/Nm4y9f8uP3hW2Ako/k8eXVe6Qb5AA4JfDk+Mj3NUCCd3AiphMK5B56Q 5UWPeaphpl+RlzMr1LW2O9ihYdR6E+feU7UGUUYs5GKBhA7Yrs0M3CRm01gK7FDCWzrw ZA4wAHp+EDgBnzSZRBfdwCWAJsajStmQPw4w1Oflv9t38noGmCC2zypp9d2aDSJ4C90n LioVe++xA/I5U/xdZNKwOo3WzG2m+j+/Twyh8HE+WXZgygZvJWVO2QngbTl3Xfo1lUsX 080g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=d0vfL0wtxNKTuJRZzHOY9w1Cq2NDD/UP5lqGU76eV0U=; b=IbAh+bs1xOAhzNfHPMXBThgC4SQqGbIr6xgUWqAewScu233VYcBW9WKMaRoi6H0ptA kRgRUbnGEdrsDDA2vZyFenJs+45jaTj6TqD4QfsV3Ws78rucM1Dm1wdSuKZwosuB0p2d ln9H9Gj6wijN0II4gTY1UdaZG2fdcm3l5iXIiBgpV9VbDOlyeo1+kQ4fXhSg+7HXx1tQ lRquCJ7cBFcBC2It+Rk55FuxKXOSXsbilF5pQ4b+pjNA++iGRx3zwdLHzv+iyBs+V4II 2VkSVDhyb05Ppm9XdPTEwvqyx1g99hPug/VrXmB24zh3aaarf1wFbooL4prQN2xkCXn3 HonA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FvNNA4E1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk7si4401900ejb.223.2021.02.11.08.51.14; Thu, 11 Feb 2021 08:51:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FvNNA4E1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231178AbhBKQu3 (ORCPT + 99 others); Thu, 11 Feb 2021 11:50:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:57474 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229993AbhBKPjl (ORCPT ); Thu, 11 Feb 2021 10:39:41 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D241064EFE; Thu, 11 Feb 2021 15:05:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613055913; bh=6PVh59eQu6Ub0inTYrwaAY4M1J0WXwtcGrWw2y8VC1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FvNNA4E1Xl6+r2CM2K9rx6WuzjApdEbjaU9xju42OVQoShZOMzuoFiJTdsN8CWnZq BDkfNs/MC5Bi4kzLveDqv/y9jmK8Fwpm/Zdi7iEMNvymPUmzahEXt9OvjnGEPK69WZ LZEWHwY32hYk4SfbO1l/3VdJwD1sk+FITmrTpNBs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , Luca Coelho , Kalle Valo , Sasha Levin Subject: [PATCH 5.10 34/54] iwlwifi: pcie: fix context info memory leak Date: Thu, 11 Feb 2021 16:02:18 +0100 Message-Id: <20210211150154.365563468@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210211150152.885701259@linuxfoundation.org> References: <20210211150152.885701259@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg [ Upstream commit 2d6bc752cc2806366d9a4fd577b3f6c1f7a7e04e ] If the image loader allocation fails, we leak all the previously allocated memory. Fix this. Signed-off-by: Johannes Berg Signed-off-by: Luca Coelho Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/iwlwifi.20210115130252.97172cbaa67c.I3473233d0ad01a71aa9400832fb2b9f494d88a11@changeid Signed-off-by: Sasha Levin --- .../net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c index d719e433a59bf..2d43899fbdd7a 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c @@ -245,8 +245,10 @@ int iwl_pcie_ctxt_info_gen3_init(struct iwl_trans *trans, /* Allocate IML */ iml_img = dma_alloc_coherent(trans->dev, trans->iml_len, &trans_pcie->iml_dma_addr, GFP_KERNEL); - if (!iml_img) - return -ENOMEM; + if (!iml_img) { + ret = -ENOMEM; + goto err_free_ctxt_info; + } memcpy(iml_img, trans->iml, trans->iml_len); @@ -284,6 +286,11 @@ int iwl_pcie_ctxt_info_gen3_init(struct iwl_trans *trans, return 0; +err_free_ctxt_info: + dma_free_coherent(trans->dev, sizeof(*trans_pcie->ctxt_info_gen3), + trans_pcie->ctxt_info_gen3, + trans_pcie->ctxt_info_dma_addr); + trans_pcie->ctxt_info_gen3 = NULL; err_free_prph_info: dma_free_coherent(trans->dev, sizeof(*prph_info), -- 2.27.0