Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2449750lqb; Mon, 27 May 2024 23:09:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUoynt6ZQnhQfV+epN8siuc7Jhj7AbAV9jDv+52vdpnzcitNUHEmJefq5O3vugNY5JARgEWlz6nnotgBYRIzkGT/dYBiaZX9KQp/dnm+g== X-Google-Smtp-Source: AGHT+IFR7QfBQXKEhqUmLf2LmASdm3juwbxGDuZ2tQ5tV2HUpiAaa5BCGKEzaQ13hF4/pg7yULpC X-Received: by 2002:a17:902:d4cd:b0:1f4:b9d3:adce with SMTP id d9443c01a7336-1f4b9d3b5fcmr32869655ad.27.1716876581956; Mon, 27 May 2024 23:09:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716876581; cv=pass; d=google.com; s=arc-20160816; b=fU1EvzgvdTllIvldexjcD1iuZZuD+nZrRETqB/bMIJCXVAsYNlPnWVI9PCHazHBBt2 MB+L9H5buK5GIADqiQkdAL7I1y73xCFmb6CTuyZERw/ltlfrV++EfTpcDbQwLcOhTftD 03qb9nWmSZEeD5uYrtC6hsp6HnhwS/oefAa/kFJvG7o5yHIqI18wiOItdDOgvf2rPY7K RnfrqXiMQTYR1anhf+Nc53Rn7MDG2mHYlMpJnHnaHpRTDG2xa36AsAxJtPCrNX76JE6v RjF6kSa2n1n9Rdq88jWZk5/qv4uo2DAnUYGVRmqJ9FfqF2OmETTTYvRXVda3laR9uyM9 RgbQ== 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=fjrF5giDo6FM11WWJ/yZ+cB6gzQE6tnTZw6XufJxPaE=; fh=87/eY8gQF4FDF3HwXnnmaJwLYvnDECX4QrU8m57oL/g=; b=LelgPnVcU6rb/89ClirAM3+AkD+BblCu8SQLO6E5xa5lnOLxoJ3n2lTQpOz3e5cKPa sKcKTcHDeFwtndIZ85y0JBQNlMoDl/7NtfHebsYopQb59+4Tvq/BQOikF2BLsXt7eypR DmZZUWF3/SRTQIDy0M4Syz6RGYfQyx7aLBT4sWya0xjfqGO96MxyCtOlqK0838gJblJF MThN+P3GojuVcsl5U3h/9VjgEoxlW8tut0DeEZ2YAaI88HmmXCHVJIdY76ERJ8ZUQFmN Tjz3wzcZe5eMVgSnigHwDsGUJVpqBzMwqyZz2TV/DpUk/OK9A2M+U+jcWJ5FJuYtRd1A FkYg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cboUSiem; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-191800-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191800-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-1f44c9a9643si72445495ad.426.2024.05.27.23.09.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 23:09:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191800-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=cboUSiem; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-191800-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191800-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 854002839D9 for ; Tue, 28 May 2024 06:09:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 183736A339; 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="cboUSiem" 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 364844F5FD; Tue, 28 May 2024 06:09:25 +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=WEJYYxlPbRGwXKIn3VzAslFqMu/d6NM8gb3gqAPNicym7v203S/34KPcIEvncmQlTRJS1UB9Dz8chEZeWQpxpgQ1fpyEIApNEYdqBKZaRaiWIz+PJu6zDH2ul1yfQEOmAC3FYINNvRRvSRJrCNv3ZCZwUKfVXD25+NtGqdmc8y4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716876565; c=relaxed/simple; bh=Eqtg8XNRPOkiV1rBmKE+E5Q17RJH/f6pOWXblhQp/oo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qOiFOhzQLmTz/gVXxh9IlcNu8lwY6+KjiWFsR18+Iocz4Zahl/uFtQMwIb+2w2UxlbtvPh0uWMLWJ5nlSdtJqVHzAXnEthOAN7/J5cuK0IXLyvetVbaDbVGqwK2hfCpN8dRngTdp1vPTKJdBkqlgj+rVX4B4vQMibmxcCMwModM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cboUSiem; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id DA425C4AF09; 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=Eqtg8XNRPOkiV1rBmKE+E5Q17RJH/f6pOWXblhQp/oo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=cboUSiem9KklcZFiXMPFFmoO869Fn7z+mlCVUx/tp3HK+Cc8XrMH4rm3LyJvhATSp 4dtV2YL/W+SLRTPu/QjGlCQ8wmPW/nG+SayWvkYKAfj09bf7u7f33jl1e/zZ4fW10n FjLsQgQjwD8Cr/vIuyUt4jvW2topU7rlEXY5iFFgUXkxPpgcch2RDdoiTwUvtnGS3I c4ZL0FYsG1sOzHVVd3Ocu6jeNOrYOyAotBTfFrmrxRHEnN5KLMEWBVlUmwhq3YQgPY mdM6iXghB9TgsCtph4dy/5nkm0a+NDVkSmo3g4Fs8L9j2P+rStSgJLvT3bYz5Q89uJ IT9WQZ58h+lfg== 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 C8FE0C27C4E; Tue, 28 May 2024 06:09:24 +0000 (UTC) From: Nikita Shubin via B4 Relay Date: Tue, 28 May 2024 09:09:25 +0300 Subject: [PATCH v2 3/3] dmaengine: ioatdma: Fix kmemleak in ioat_pci_probe() 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-3-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=1823; i=n.shubin@yadro.com; s=20230718; h=from:subject:message-id; bh=tibFMcaMMDINAMULT2DBvxJYeYcAsWOCGa6cDYv40uU=; b=Spd8wOljNfdMMhAzdRsBkqUw7Og0HFDv9oagQ2CV4x/zau+jRsHiHjlwwnYJMz6jjFm38Gzeif5N xvJJmEOnDPT6u6tYxvot0aqRUcWdbEYraI1TO2qjxXOxk6eLRGxh 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 If probing fails we end up with leaking ioatdma_device and each allocated channel. Following kmemleak easy to reproduce by injecting an error in ioat_alloc_chan_resources() when doing ioat_dma_self_test(). unreferenced object 0xffff888014ad5800 (size 1024): [..] [] kmemleak_alloc+0x4a/0x80 [] kmalloc_trace+0x270/0x2f0 [] ioat_pci_probe+0xc1/0x1c0 [ioatdma] [..] repeated for each ioatdma channel: unreferenced object 0xffff8880148e5c00 (size 512): [..] [] kmemleak_alloc+0x4a/0x80 [] kmalloc_trace+0x270/0x2f0 [] ioat_enumerate_channels+0x101/0x2d0 [ioatdma] [] ioat3_dma_probe+0x4d6/0x970 [ioatdma] [] ioat_pci_probe+0x181/0x1c0 [ioatdma] [..] Fixes: bf453a0a18b2 ("dmaengine: ioat: Support in-use unbind") Signed-off-by: Nikita Shubin --- drivers/dma/ioat/init.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c index 26964b7c8cf1..cf688b0c8444 100644 --- a/drivers/dma/ioat/init.c +++ b/drivers/dma/ioat/init.c @@ -1347,6 +1347,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; + unsigned int i; u8 version; int err; @@ -1384,6 +1385,9 @@ static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) err = ioat3_dma_probe(device, ioat_dca_enabled); if (err) { + for (i = 0; i < IOAT_MAX_CHANS; i++) + kfree(device->idx[i]); + kfree(device); dev_err(dev, "Intel(R) I/OAT DMA Engine init failed\n"); return -ENODEV; } -- 2.43.2