Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp630662pxv; Thu, 15 Jul 2021 11:59:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPTyE6iDFAfXPgTg8Nao04Ynp547WGXutlh7DrbSdxsOtEed1m8ZrDGww+gkcnQGao7thU X-Received: by 2002:a05:6602:190:: with SMTP id m16mr4308704ioo.14.1626375590680; Thu, 15 Jul 2021 11:59:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375590; cv=none; d=google.com; s=arc-20160816; b=E3AMxDD70P8sZnK5+SbTolfJTQ7x0MrSsBU98nZP2m08+MYHiiJSna8QPTi/oKZOlO WBsDfEpSTqIlsyaUlkbeZqTqlZSCNILaG3FXW2smqUfqAMwHZIcSvvDTZLFDzs5AhFkf l2MOnysBSqqaQI815ty8vMtpqMXKcGcJOoCTb7tnCYOfuuTDpC0MX12L6eyWzhGgjTPO Pan+2d5uSLLNC19Kk0WbnfnvgbZh54NeexYrWuc6cctaA0DQ98IMExqsoTq+ziKMj0IO BC4trEByvUOsOJHmpeXdmuaA4ADw7CX8rcfx2Ojoh6lJ5LJEr4HMWcgpCgTUoFYtXZhG GL7w== 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=ukLEgFqNj2KW6GZsivIZ1zxCHYrw6TJ3g0m21Lo3NuQ=; b=QrGmAAIawi62gjo+HmTSk6e4jd6dPWfrngVZZofwldIt0xLNSQjNTkr/FEbwPgjL2t Qs1DCXLO2Er7ktxfJoeplQ0sqxuY3bVZEtBK0MHXVPptywp9WncnDQnhjT9TAl02bG8s IZ3XF3lJ3sjGo9TCp82GHHPnD8ftj0zfzmz29/8PgkYXWETaQRi+3FD6xH/3FNGq9e6A ma0pUWH9WAE09fy40GRENho6jzFzD0eeTowjVFBCD7X7ZwdRp4TEFmgUrfJOadNhlYTO o2GqwxoT7dTPBsuf6BtmnSfnPbgZgKpvl1TomR9IXql9Gr12U8wLxNX1PbdOh5Az9Gum gyrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tsoKUrwd; 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 k14si7403794iol.64.2021.07.15.11.59.38; Thu, 15 Jul 2021 11:59:50 -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=tsoKUrwd; 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 S242589AbhGOTBR (ORCPT + 99 others); Thu, 15 Jul 2021 15:01:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:57072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240667AbhGOSxv (ORCPT ); Thu, 15 Jul 2021 14:53:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5793D613DB; Thu, 15 Jul 2021 18:50:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375057; bh=UgTOyG//4UrPg7Ha48n4W39sIt64DI2Mai1IMIbKssA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tsoKUrwdTYIkUUShJ+8x8+whgrX4qlbRWoKiKoQ/VJL4C96+MpEuevvqdctAZJHkF KsYHBE8251OzAbVx+fGYP0DTX/5IJkXlDKnhJd7BjHDxWeoeWVs7Ob0wTXxSSSBhAy tw3enbXYjA1Ma3Y//ZP9UAfkPiyRqGkwqEZZmsUU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , Luca Coelho , Sasha Levin Subject: [PATCH 5.10 104/215] iwlwifi: pcie: free IML DMA memory allocation Date: Thu, 15 Jul 2021 20:37:56 +0200 Message-Id: <20210715182617.722485825@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@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 310f60f53a86eba680d9bc20a371e13b06a5f903 ] In the case of gen3 devices with image loader (IML) support, we were leaking the IML DMA allocation and never freeing it. Fix that. Signed-off-by: Johannes Berg Signed-off-by: Luca Coelho Link: https://lore.kernel.org/r/iwlwifi.20210618105614.07e117dbedb7.I7bb9ebbe0617656986c2a598ea5e827b533bd3b9@changeid Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin --- .../wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c | 15 ++++++++++----- .../net/wireless/intel/iwlwifi/pcie/internal.h | 3 +++ 2 files changed, 13 insertions(+), 5 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 ec1d6025081d..56f63f5f5dd3 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c @@ -126,7 +126,6 @@ int iwl_pcie_ctxt_info_gen3_init(struct iwl_trans *trans, struct iwl_prph_scratch *prph_scratch; struct iwl_prph_scratch_ctrl_cfg *prph_sc_ctrl; struct iwl_prph_info *prph_info; - void *iml_img; u32 control_flags = 0; int ret; int cmdq_size = max_t(u32, IWL_CMD_QUEUE_SIZE, @@ -234,14 +233,15 @@ int iwl_pcie_ctxt_info_gen3_init(struct iwl_trans *trans, trans_pcie->prph_scratch = prph_scratch; /* Allocate IML */ - iml_img = dma_alloc_coherent(trans->dev, trans->iml_len, - &trans_pcie->iml_dma_addr, GFP_KERNEL); - if (!iml_img) { + trans_pcie->iml = dma_alloc_coherent(trans->dev, trans->iml_len, + &trans_pcie->iml_dma_addr, + GFP_KERNEL); + if (!trans_pcie->iml) { ret = -ENOMEM; goto err_free_ctxt_info; } - memcpy(iml_img, trans->iml, trans->iml_len); + memcpy(trans_pcie->iml, trans->iml, trans->iml_len); iwl_enable_fw_load_int_ctx_info(trans); @@ -290,6 +290,11 @@ void iwl_pcie_ctxt_info_gen3_free(struct iwl_trans *trans) trans_pcie->ctxt_info_dma_addr = 0; trans_pcie->ctxt_info_gen3 = NULL; + dma_free_coherent(trans->dev, trans->iml_len, trans_pcie->iml, + trans_pcie->iml_dma_addr); + trans_pcie->iml_dma_addr = 0; + trans_pcie->iml = NULL; + iwl_pcie_ctxt_info_free_fw_img(trans); dma_free_coherent(trans->dev, sizeof(*trans_pcie->prph_scratch), diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h index ff542d2f0054..f05025e8d11d 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h +++ b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h @@ -336,6 +336,8 @@ struct cont_rec { * Context information addresses will be taken from here. * This is driver's local copy for keeping track of size and * count for allocating and freeing the memory. + * @iml: image loader image virtual address + * @iml_dma_addr: image loader image DMA address * @trans: pointer to the generic transport area * @scd_base_addr: scheduler sram base address in SRAM * @kw: keep warm address @@ -388,6 +390,7 @@ struct iwl_trans_pcie { }; struct iwl_prph_info *prph_info; struct iwl_prph_scratch *prph_scratch; + void *iml; dma_addr_t ctxt_info_dma_addr; dma_addr_t prph_info_dma_addr; dma_addr_t prph_scratch_dma_addr; -- 2.30.2