Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2372259pxb; Mon, 20 Sep 2021 20:30:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5bI+bUgZJBGP+Pp4IkZzyGB4c98vVHjTcU5wReDehL0wpYrENNWIj5ducv//7iRajFtFt X-Received: by 2002:a17:906:180a:: with SMTP id v10mr32366273eje.112.1632195037476; Mon, 20 Sep 2021 20:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632195037; cv=none; d=google.com; s=arc-20160816; b=nUaZCZH4cnG/rYrMwscKsbvOPFN+6ntEL4aX6usxbgZ3dKFr/6TkK/sZljZM6ardGa p1rC2zoCgXWsZLBdz/Fswe4DymmqFvM737xN9GP7cnsR5riooQFsBwYDQYzMIq/HQogE TCohPQOtR6NlB1o++i/AkeaowgMaX19QJEYX1gI+iBqOtApAZMWWB4xnSw/HNoB0TyCA X8w26X59IVerZy9xCCWV675c+giZ54jGktlwiwN03NSW1LLTyM7bV1U0ccb5X1mkPJZW p1p+1M+F2qRc7O341o/89UsPTnJSWURefoWCjSgdDO/oNcmD49KzMx9RAkq/eAhYlRLt YCaA== 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=bXx4MBEPsw7lpk2wN0UNXt870wVyROa7g1SqS3sE3kQ=; b=Ntvz9FWnRiPIM9wLpFdtci6m/BRCB86gMH39CKYlLdzq7tpOgK212srhiQvNo1Nxwd lQj5MlPaKm1eI1trPtEbvavuM9KL7bDWY1zCWihJu0f6EslAKJ4FL4abI2kTHc8up0U1 p/byhzqLOHJZX9O8xV67FrusUQxq1F/sDWpEHPrBttcKYSmc8ppFnTCds1u6Ss2CQdVr OMsBwEsJiQHhWCB95qWwcvwbSwK8EdCDYJD3XUkw18Zcs3PUv5W8IIe4QSKuoYPRwina hADxrH3hV58YLZmZLyA+hNeMzm9aDkicOE+TpFMfdThHYozx6pQ5eZmvx18Ee2oUObOD Kc6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Vau+EKmz; 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 y11si13952616edj.69.2021.09.20.20.30.14; Mon, 20 Sep 2021 20:30:37 -0700 (PDT) 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=Vau+EKmz; 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 S1349953AbhITSwq (ORCPT + 99 others); Mon, 20 Sep 2021 14:52:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:33246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385436AbhITSu0 (ORCPT ); Mon, 20 Sep 2021 14:50:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AD3C261371; Mon, 20 Sep 2021 17:34:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632159283; bh=m3/X0nqi7M3hpujLanY9ZYmazN/XQXQIXcCIK34Dzao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vau+EKmzs73bin6FSlJjlvKWhk2gFotRivGD5kOANqeAQ4obFOq/CfU1lBTn4zMJk 8+lHHsdTBa4OiQPjTrd+Y/kYiUcPtB0rKkWkhUqqczzqscrJ2HwqKtnX1McPHPoE3x JDJcLW9JlV3nTVrFBu0xTkUvrM5dQBvtJ1LQG8ic= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Dan Carpenter , Luca Coelho , Kalle Valo , Sasha Levin Subject: [PATCH 5.14 159/168] iwlwifi: pnvm: Fix a memory leak in iwl_pnvm_get_from_fs() Date: Mon, 20 Sep 2021 18:44:57 +0200 Message-Id: <20210920163926.894504439@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163921.633181900@linuxfoundation.org> References: <20210920163921.633181900@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: Christophe JAILLET [ Upstream commit 45010c080e6e7434fcae73212b0087a03590049f ] A firmware is requested but never released in this function. This leads to a memory leak in the normal execution path. Add the missing 'release_firmware()' call. Also introduce a temp variable (new_len) in order to keep the value of 'pnvm->size' after the firmware has been released. Fixes: cdda18fbbefa ("iwlwifi: pnvm: move file loading code to a separate function") Signed-off-by: Christophe JAILLET Reviewed-by: Dan Carpenter Acked-by: Luca Coelho Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1b5d80f54c1dbf85710fd285243932943b498fe7.1630614969.git.christophe.jaillet@wanadoo.fr Signed-off-by: Sasha Levin --- drivers/net/wireless/intel/iwlwifi/fw/pnvm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c index 830257e94126..513f9e538729 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c +++ b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c @@ -231,6 +231,7 @@ static int iwl_pnvm_get_from_fs(struct iwl_trans *trans, u8 **data, size_t *len) { const struct firmware *pnvm; char pnvm_name[MAX_PNVM_NAME]; + size_t new_len; int ret; iwl_pnvm_get_fs_name(trans, pnvm_name, sizeof(pnvm_name)); @@ -242,11 +243,14 @@ static int iwl_pnvm_get_from_fs(struct iwl_trans *trans, u8 **data, size_t *len) return ret; } + new_len = pnvm->size; *data = kmemdup(pnvm->data, pnvm->size, GFP_KERNEL); + release_firmware(pnvm); + if (!*data) return -ENOMEM; - *len = pnvm->size; + *len = new_len; return 0; } -- 2.30.2