From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 036041836CB; Wed, 3 Jul 2024 11:07:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720004871; cv=none; b=LTaycgwiatI7/KCPk2ZF1LWcEiO2Yj35PzwTZofmVZjX4CeZ8Li3GjJj287y3OrHH4pPl0TYsLQq2+B6Rw4n8ydZELP2w5LUnv1rJV5G39Le1wvfzWzr2Wbt3h2xU0cjv5KJXuC7hOTrDdoZ2AA0ExaF/Qj/Zvu6A13ldKpcAhs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720004871; c=relaxed/simple; bh=AccEMUwPELmxY7z1EBYbbwfdNhkyRUrdwgPXLRCjF58=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BuoAzdCd2+QZufSwJ+y/so+xJWyAf3qL5z8jI51Azqkn/l0vALwCkAtO+KzZWEm9kasoHdbu5TePsoOKEKFi9QUTzLqBpemJcQ0Bkct2QEg3KZ0MqDa7CfvMKx9BtSqgYJeq7tamaCe0RtkrHTXzsjq7OlpY/1F/OYVHJVh961k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ofGc0yRm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ofGc0yRm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C63AC2BD10; Wed, 3 Jul 2024 11:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1720004870; bh=AccEMUwPELmxY7z1EBYbbwfdNhkyRUrdwgPXLRCjF58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ofGc0yRm4cKSaQhd6AHIphnuVymiKuGcZa55kVDW3IUpGrIJ7a8XXXAJsBxmlQlgk Tt6lUXoxp1NTbxJN+g0Kxib5EfN/jAprm1zIwneehRBs3xUKySNfGV5sah1fzHsWO2 bGdxlbHGcby3qnzv/rEOOG/cK0vn/+Wh0Fw1w1Js= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nikita Shubin , Dave Jiang , Vinod Koul , Sasha Levin Subject: [PATCH 5.10 157/290] dmaengine: ioatdma: Fix leaking on version mismatch Date: Wed, 3 Jul 2024 12:38:58 +0200 Message-ID: <20240703102910.109774598@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240703102904.170852981@linuxfoundation.org> References: <20240703102904.170852981@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nikita Shubin [ Upstream commit 1b11b4ef6bd68591dcaf8423c7d05e794e6aec6f ] Fix leaking ioatdma_device if I/OAT version is less than IOAT_VER_3_0. Fixes: bf453a0a18b2 ("dmaengine: ioat: Support in-use unbind") Signed-off-by: Nikita Shubin Reviewed-by: Dave Jiang Link: https://lore.kernel.org/r/20240528-ioatdma-fixes-v2-1-a9f2fbe26ab1@yadro.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/ioat/init.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c index 783d4e740f115..6c27980a5ec8f 100644 --- a/drivers/dma/ioat/init.c +++ b/drivers/dma/ioat/init.c @@ -1349,6 +1349,7 @@ static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) void __iomem * const *iomap; struct device *dev = &pdev->dev; struct ioatdma_device *device; + u8 version; int err; err = pcim_enable_device(pdev); @@ -1362,6 +1363,10 @@ static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (!iomap) return -ENOMEM; + version = readb(iomap[IOAT_MMIO_BAR] + IOAT_VER_OFFSET); + if (version < IOAT_VER_3_0) + return -ENODEV; + err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); if (err) err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); @@ -1374,16 +1379,14 @@ static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) pci_set_master(pdev); pci_set_drvdata(pdev, device); - device->version = readb(device->reg_base + IOAT_VER_OFFSET); + device->version = version; if (device->version >= IOAT_VER_3_4) ioat_dca_enabled = 0; - if (device->version >= IOAT_VER_3_0) { - if (is_skx_ioat(pdev)) - device->version = IOAT_VER_3_2; - err = ioat3_dma_probe(device, ioat_dca_enabled); - } else - return -ENODEV; + if (is_skx_ioat(pdev)) + device->version = IOAT_VER_3_2; + + err = ioat3_dma_probe(device, ioat_dca_enabled); if (err) { dev_err(dev, "Intel(R) I/OAT DMA Engine init failed\n"); return -ENODEV; -- 2.43.0