Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp655140pxv; Thu, 15 Jul 2021 12:36:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxK2z47NscmlRlMGtgKuagvIWaeCC9VQNKltkpVHWIB2tgmvawNISlC3rAzqlHl2EtpcICi X-Received: by 2002:a17:906:4ad9:: with SMTP id u25mr7245838ejt.174.1626377785433; Thu, 15 Jul 2021 12:36:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626377785; cv=none; d=google.com; s=arc-20160816; b=fGOlKcUCxN0i+ktGqI8qe3GbeSUqTW8WDKNM6IEJxTcqGNUVECIYXr1cwnUjiYEZ94 0Ls/s9x+e5eKvNnl2SG0mItaz4QGblPOV+3S9VR1d6lmxJ112A+4hB3MJUDF8o9hcLAU ty9Bb7jy+9OYtmtkXMq8Jhz018q7oJrzT02PAdsxb2DpDBnLBg2csI5cBt+K0EdqV6YL HaICtmeBTdCv3MV65/Jccw0uRtiRE5WMruLy7ZJ8CgZr4QnjJ6dSjDcfNflaGyIcnP3W flTUdzxK/n7xqMIly/5GCvtYH24rpzSWAI1de5bEEhppr1zdow4Q6ypxdhjbZl1FUeAb mOUQ== 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=CIvxxj986Ir5InWUg330+aN+MyLPfFobrKaOMCD5Xj0=; b=z/li5OheagN//T1CXy2VToV2Wi/7cdWt9SnRN0lSnPhrgWhzbFqwr0xkOoc6h52pEs /tFrFtUy11KAME9LGeP3GiKwn9k7RqpcaYZ08xMpiDlXBniVnJx1em+Nt32GiDSB6Y3r sZtnlyinQp4M+lqKDXkD5ZuKQVXRVln7FbszFtN9BMOasfvZXvDbDO8RA5ICdabtwxx6 yjoeJ/NMNIduM39rO/7kJX1336HvkU4HEDmXqjOIbwEBpOqS1zuN3VepjlPbOHsNBIzL 7k5r90CJ7SwRG04kpWtAHFET/y0sgmct8fEZw+jfa/rD5h9zR/fMNT6gr4cFka138mnE ghag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ja4YZWgs; 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 q16si8369349edr.89.2021.07.15.12.36.02; Thu, 15 Jul 2021 12:36:25 -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=Ja4YZWgs; 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 S1344738AbhGOTf2 (ORCPT + 99 others); Thu, 15 Jul 2021 15:35:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:50542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243841AbhGOTL6 (ORCPT ); Thu, 15 Jul 2021 15:11:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 520FB613F3; Thu, 15 Jul 2021 19:08:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376133; bh=IVksoe3Tgd8OMjyg+NmC5JQaVrxrvAgCWWo0M5unzU4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ja4YZWgs627fPBYreOG0W/w/+1ZoT6NC1jc4FHBmzNAaAWc5OO6tDbgqghZWQ47Ov 78gBusvpceX34NCUNeby1z2T43d6pbIEqBM9DNJcaaQrwXjFt5RhNG0CP0fRDMT0Cm D2a3jE3QJpQc8KKlUtyXvCSmAlQBenfpsF6ANqS0= 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.13 141/266] iwlwifi: pcie: free IML DMA memory allocation Date: Thu, 15 Jul 2021 20:38:16 +0200 Message-Id: <20210715182638.532172923@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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 cecc32e7dbe8..2dbc51daa2f8 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c @@ -79,7 +79,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, @@ -187,14 +186,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); @@ -243,6 +243,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 76a512cd2e5c..3f7cfbf707fd 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h +++ b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h @@ -279,6 +279,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 @@ -329,6 +331,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