Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2449742lqb; Mon, 27 May 2024 23:09:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVPBR8z19nIuW5yBCXzJ0pHCX+PHIpL6syRF24xkrub7SGorCfDZtj1Nt7kiQosxKVaThcYL91k8gEUKKPMHG4JRpqTuxLr5fOQS6b4vQ== X-Google-Smtp-Source: AGHT+IEAmShdR1LMp40Z5OUu7uU/WIglvcRc+wJCeRuxZTFl6cFPH7QfvrT37KljkG97xppp0eeM X-Received: by 2002:a17:903:1208:b0:1f2:f46a:41bf with SMTP id d9443c01a7336-1f4498f0c2bmr127375325ad.57.1716876580926; Mon, 27 May 2024 23:09:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716876580; cv=pass; d=google.com; s=arc-20160816; b=R3eYX6b3hFtY8DtCGOc2u15RU/4byGEhnktQVd4EtMNtahZtIQyxazCoA1Lk6wf6Rd x59M4HRlAE+7zZCEoHW1Puou3Fui/CQO2AMgEtdXGPFjX9RxSgLWreBCygBomyvKm/VG n1HsZLM6KFYi4QCzLjS5X4ZoCmJgMCwihTmbFnc0eTu0ieAc+/GyRyYO+/Z3b4FGYcWw Cf6UFZpbaVT3Q9QwgFjmwmZGyF/s/nyNtaWxDc+Eb+Rz8ft+fVFxp6PvDF2pZHj28UCC iPDT3NynvTD/JpfSMwESsAOvJaGZOfcrqQbQ8CI7bplo6QPqBEwuIfHBDloHUyssoJHL hyrQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=syCRI6PB9YzScRbSqY//G01FsRiDYY1E01oDXGx8zp0=; fh=87/eY8gQF4FDF3HwXnnmaJwLYvnDECX4QrU8m57oL/g=; b=lG44RYDkKUK4OGriDGZvWudQF5Y6JjDQbCZAoeO2EkwPLHFQTUC01fM5lZeyvEd8Jc mCav8FLzVZRxMfuoiZF2nAIDWGYnTpgwrSPqRHmfti0XVhslqeVu2znpdHNUI6NJBm/0 QpiiAhD52C+O90ozOOzgLwyEHiso+hugXV2nM00LFiTlj+NlWIJT0QVA5cm9zDMAGFFe gYW2mXLqH6p85lK90uKQRgpXkZ/EP633ISR43/DqnbBH18R9q1ueUSYlq/p/1i/jaMXv jz5z3N0aZmAao/aTQabiFOJdwsMYLtzCkAuU5PCxlSlRJ9gAPqjlCO7toEj4BNQIB+I3 oj6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=in+WL5mo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-191797-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191797-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c9cc391si71172555ad.503.2024.05.27.23.09.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 23:09:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191797-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=in+WL5mo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-191797-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191797-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8AB6228394F for ; Tue, 28 May 2024 06:09:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0EA414E1CA; Tue, 28 May 2024 06:09:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="in+WL5mo" 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 2E876DF6B; Tue, 28 May 2024 06:09:24 +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=1716876565; cv=none; b=tyjcgKRmZJ/ZxJ3efVVNCBldLnTW0YciY+QP5v94VtdIAqh7Vj9E/g2P3P8dmdaVYGc24bdYntN+51YW7eo4sMRcGvocFxOK5k+Kxmyjj2w2hkLcv+sXsyYMOTFEZ5mRTEXPcTRluL/FVhiWqOVcNlJXKiE/CwFEMIImesKKO14= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716876565; c=relaxed/simple; bh=nKrlwxVQZ9JWwpGEnhgFrcVm0BXTkJ1KgeGuEWOqKj8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hT9IZvq1fw6v3LHjyco15exRiw+S9mCywojOab/KqecPcktfp89ZPR30TQ0n8iOC/oEldWsgNAph6sVV+QrZEdhUl+X+0GdcWPIosNhtaOtKQR2Rk+HMTYRO85oHVdvFOd29C6g+uXboawWe5nlfqG/Z6ixHOjw84YiE0WQfHeI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=in+WL5mo; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id CAA5FC32786; Tue, 28 May 2024 06:09:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716876564; bh=nKrlwxVQZ9JWwpGEnhgFrcVm0BXTkJ1KgeGuEWOqKj8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=in+WL5mous3ATfr/+7DOLw07nAg78gfEuavJmC7UPmOOqUNO5ut+txv2j8/x/v8CM l6L66bVFW3OEw1wWmjkVOcT6BPfcWwoed7+aa2yO0SwYJ0xFQ7CxGrleb+FNWh/vMw oh7MFiQslGW9M6ZtuDlNJ9ipZme6TaQTfWLC6YTet0uOV8fdbAZhaNB3Fgveb3lL8F y/2DT7JD+xYa/sX3fPuz0aZGFTB8gAfkTctUWQyaeB54e4naMO/p2XntKKytg7MYej 82iIbErXcihXmOErJy43MpZ3S7eZBH/LCi2gS3EXmV3GSRURPVVJdLfn1a07C0kxIW DDAei6h2fBHrQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0E2AC25B7E; Tue, 28 May 2024 06:09:24 +0000 (UTC) From: Nikita Shubin via B4 Relay Date: Tue, 28 May 2024 09:09:23 +0300 Subject: [PATCH v2 1/3] dmaengine: ioatdma: Fix leaking on version mismatch Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240528-ioatdma-fixes-v2-1-a9f2fbe26ab1@yadro.com> References: <20240528-ioatdma-fixes-v2-0-a9f2fbe26ab1@yadro.com> In-Reply-To: <20240528-ioatdma-fixes-v2-0-a9f2fbe26ab1@yadro.com> To: Vinod Koul , Dave Jiang , Logan Gunthorpe Cc: Andy Shevchenko , Nikita Shubin , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux@yadro.com, Nikita Shubin X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1716876563; l=1829; i=n.shubin@yadro.com; s=20230718; h=from:subject:message-id; bh=ASVt6+nzAUVivKjUfhTrAzVsAPEzKEYVziXwIRDAuFU=; b=vpo6veO0EiOXKv0hYhTJJNEvRbRU1sbfQMuG2vWjy3lqgJHqU2tqnTVFSN2z+ubGZBVJX9qAa3xx v7zI2MRnCM0apPH/L8dPZb4icGLoAUz5mBQ0Q4nL3QtIGKaDJ/Yy X-Developer-Key: i=n.shubin@yadro.com; a=ed25519; pk=vqf5YIUJ7BJv3EJFaNNxWZgGuMgDH6rwufTLflwU9ac= X-Endpoint-Received: by B4 Relay for n.shubin@yadro.com/20230718 with auth_id=161 X-Original-From: Nikita Shubin Reply-To: n.shubin@yadro.com From: Nikita Shubin 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 --- 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 9c364e92cb82..e76e507ae898 100644 --- a/drivers/dma/ioat/init.c +++ b/drivers/dma/ioat/init.c @@ -1350,6 +1350,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); @@ -1363,6 +1364,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) return err; @@ -1373,16 +1378,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.2