From nobody Mon Aug 24 04:17:45 2026 Received: from BL0PR03CU003.outbound.protection.outlook.com (mail-eastusazon11012001.outbound.protection.outlook.com [52.101.53.1]) (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 F162A3B38B1; Sun, 16 Aug 2026 15:49:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.53.1 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786895388; cv=fail; b=cUZycaZvAMx5Ilpw24R4Mux5/lLb576ZsCwPN1FT0whwNJDYOYl6kx+9jpbSSdRfMvvX3n5fcirM+JCxP/qTabVGo1FXwcobuaHWheJKaJwjjYo83btTfkM+6SNG4C7Rfkyv+cpkI+8iOPuKO+Q8iNKQOuNrfvrnQoC4ebmzias= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786895388; c=relaxed/simple; bh=tXtFzgzRwDCoBIz7yUWi4LDyktAyPuM/UleZbF2G8EU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=QCXhl7VPXfaXQLYbhj25Euep6HMZRnHj5neabUFkGO46nFgMXQBxXhj6NmPhY7RrOLHgG8w5ZSRBcWYQ1C576ahCINDUUluGIScj3j1ao1g57zZeTfsWNtDnRn1nN6dZ0LsT2/uXobTCHBitZRdfdXAvbDZu8OEpmp5ITcNh3VA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=ppMEn9Yp; arc=fail smtp.client-ip=52.101.53.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="ppMEn9Yp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lFeex23OlrMQpIfgj/LgH8uPlOG8JA5S+1+pmWSRbx6mWMp0DmASDS2yhxDg9/9rpTwaR0UkkkGJpMkzHJo4zg6dY+bW0NKgQmMweQthA0mCDLe1bqnKG2epm/Z9ulLPaguaXnwgvKBXGN+gbGaG64rQ1UwVo4r1B+hA87T1YBCTsbbbeLu+Dc1x96FSCuBrlGHo1GMlujkDHJuS9wGNolrLXvTsBVey/n4ncdV/6WkFVpTKOfO0lQUP78HXJOCMp4Fib82cVsN+2rQ2iIgnA/8GTFiwpT/eyyUL9iU98JMEjCuFRYaQbG3/TjuSGioS1tlR0dhnxURaRU4EGoLb9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AxxTVr0aLE2WJKC790igZe6Hds30nyDVlgVGwpefJLY=; b=thwp8/w/VbHFKcr5Ra2t2OXci11/zMnOgYDvTrQbNp9suC5ihRIkxhijunrrbi3gtxWsAYOpnajWgAb3eqUQGz93JnOO+8aE485WzMzuJZ9gpAzjfatss+CZjOmbVta6q7kLQohgIogNcMUi5KfWq9LgBQrULaIogoWYad+PHxuHxz7OcpfKcf2PmjABtALhNca4hTojQFLPk84muMI4ywRmvKQYzTu/a3mDoY2XH6kii52U9eP9EGI/SMLntd8HjvRKjTaDuhURQeaTO5Nu626ZkWmAbADxqetIT68PRquQCXQ3TrntGPPJAgHy/trXD8NRKPhBRfElRCIPfDyPgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AxxTVr0aLE2WJKC790igZe6Hds30nyDVlgVGwpefJLY=; b=ppMEn9YpvUB+g+TcItqf9oLPP4NCu7hKCZ2xK6r+A3fQ/6d25JOgyxcouUq/B4B7ViGZArMAUT32ZWcf3N/0NbfG3GzjkEC+XaV1OijUFf2OsLENTKAimmbgn1GKs4BjFb8LDlm1CcFp1c62t0J0VbllXW39qYTvIP2ELuU5rFQ= Received: from CH2PR16CA0014.namprd16.prod.outlook.com (2603:10b6:610:50::24) by CH2PR12MB4120.namprd12.prod.outlook.com (2603:10b6:610:7b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.17; Sun, 16 Aug 2026 15:49:40 +0000 Received: from CH1PEPF0000AD79.namprd04.prod.outlook.com (2603:10b6:610:50:cafe::1) by CH2PR16CA0014.outlook.office365.com (2603:10b6:610:50::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.17 via Frontend Transport; Sun, 16 Aug 2026 15:49:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH1PEPF0000AD79.mail.protection.outlook.com (10.167.244.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.3 via Frontend Transport; Sun, 16 Aug 2026 15:49:39 +0000 Received: from [127.0.1.1] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Sun, 16 Aug 2026 10:49:36 -0500 From: Shivank Garg Date: Sun, 16 Aug 2026 15:49:25 +0000 Subject: [PATCH v3 1/3] dmaengine: Fix device kref underflow in dma_chan_put() 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: quoted-printable Message-ID: <20260816-dmaengine-kref-fix-v3-1-7e76187145df@amd.com> References: <20260816-dmaengine-kref-fix-v3-0-7e76187145df@amd.com> In-Reply-To: <20260816-dmaengine-kref-fix-v3-0-7e76187145df@amd.com> To: Vinod Koul , Frank Li , "Logan Gunthorpe" , Andrew Morton CC: , , , Shivank Garg X-Mailer: b4 0.15-dev-47d62 X-Developer-Signature: v=1; a=ed25519-sha256; t=1786895373; l=1527; i=shivankg@amd.com; s=20260518; h=from:subject:message-id; bh=tXtFzgzRwDCoBIz7yUWi4LDyktAyPuM/UleZbF2G8EU=; b=DgXd9eN2BiPe/7JCjFTzq8eDmtCpm3UcAkskneEjJw3wJmxjTgDoFrz1DcJdGJi9/S6Va3Su4 xKeJi93UWV7BLVHSGKjdZGPO0Gyx2wOzFVoti2L2ljgCfIC9jMspBPp X-Developer-Key: i=shivankg@amd.com; a=ed25519; pk=2l2QGTeXuGkZTtfmx0nPQU8iFZfjYmX/ymMojitevx4= X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD79:EE_|CH2PR12MB4120:EE_ X-MS-Office365-Filtering-Correlation-Id: cda860cc-d4d2-40f7-8451-08defbadfb0d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|23010399003|376014|82310400026|18002099003|22082099003|10067099003|56012099006|11063799006; X-Microsoft-Antispam-Message-Info: PmSRRHSUS/dWfzIW8qhkPnQUHtzBKNvuU6ZpmFL48BqVbhq98IH777SoeuS57jaKwTcjuxm+G+lt6TlS6MqInI7ovB3IB6Y8xkCWfZAPJiAVAS283ypECXGh9TiELoZLFnjgJ/714/HPOoBt2+tyTRUKhdgY0Hp5zkUszwqfnwEVf5EI5xVR+le1Sd8PeSIo9q2yrNYzuNUrVKX+qa07LvoebM/3kGcBDwt5mBfqeibwQzWSrY+ffnpjCG9b1Qyrpvm1c5mQEve5jMjyI8jLgkpxeg3YB8+LgW5sXoMly6urKDZmDmlzXS9ex+ZfNBfLtkBg8p2Y8958Y2bUA96s/sHUQ5wToxv+fQ7lgK7oNkDoiknczusxOj5IIHcCi/x5mp75Pl/2qg/LKs3gNCCaS7731B6lU3jywBW7TE/5dLj0gMfGY98IGdHHp4czzsgEbxPKKVzOHQkCzeB/ZbIOFm2Ag1YBNeiYNo//iDeZnpEKohXJPlyzOaAdeXXw+WAm6Vt4L8BSLFTsAhNHMeWiMd0slUbgGdxZo3I4r8dMKvWoI3IvReLU6P1JoRILD+at/+ucPhmn8GQAKP0RC2Rij2YoMbO+KPHbRRKPtPpprqPCfK6Kd1ykl/85wjT+XCtMhH/VLVo/NFoEumSUvHW9oba6kIShr0NQ4FWA3yrtChH6o45v43Rsblyz5oDedRGstqvn1QV5n+/P3+gq1ON5dA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700016)(23010399003)(376014)(82310400026)(18002099003)(22082099003)(10067099003)(56012099006)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: H/ZOi6jdJX3R94O15rHUHQxz7OZwsNQsRsfIMwXN77CX+7tjaHLihxyQaFgRndUw5luuHSUHpd0M3FaicNzZlzuy2kxrGNZqgUhCbyM4ojGs+rTvLIK2nGE7zJKj2/lOmFTLVPTAvfsOQ4b0YBf9O7AZ7lJxn8notpuYGRB7Uoqqgkw0bSnBnLJ6SFLP9mdWylN0yWifwyp5121v4+h5i4ocBw/WkqlgOJHKqI1+cFhokyo5Kq7wR+BjYPH5OFkWgFxrooHhb1dGomhHrShVFM7xO/xEHhFZ+9fVr4m3E7+7/7I+KgFo1nK0XtQgmIV8ioMilwSTmisEteI5HF3rdUs0U2zYbz1EvODzNHrltNIA/5U/8WLsxPteQvrBsR5Aupfjh6m4hAffxpCAbnFszTXsLR75WrbWnU/CPb3XuD2HUpzVUkKwplp/yqqH2TYe X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2026 15:49:39.2540 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cda860cc-d4d2-40f7-8451-08defbadfb0d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD79.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4120 dma_chan_get() takes chan->device->ref only on the slow path: /* no kref on fast path */ if (chan->client_count) { __module_get(owner); chan->client_count++; return 0; } if (!try_module_get(owner)) return -ENODEV; ret =3D kref_get_unless_zero(&chan->device->ref); dma_chan_put() drops the ref unconditionally, so every fast-path get/put pair drops one extra device reference. The bug fires when two conditions hold together: a non-private provider has a persistent client holding chan->client_count > 0 and another client cycles dmaengine_get()/dmaengine_put(). When the kref hits zero, the subsequent dma_find_channel() returns NULL even though the provider module is still loaded. Fix this by dropping device->ref only on the last put, matching the single slow-path get. Fixes: 8ad342a86359 ("dmaengine: Add reference counting to dma_device struc= t") Signed-off-by: Shivank Garg Reviewed-by: Frank Li --- drivers/dma/dmaengine.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 6ffd8bd82154..516d6d933208 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -515,7 +515,9 @@ static void dma_chan_put(struct dma_chan *chan) chan->route_data =3D NULL; } =20 - dma_device_put(chan->device); + /* This channel is not in use anymore, drop the device ref */ + if (!chan->client_count) + dma_device_put(chan->device); module_put(dma_chan_to_owner(chan)); } =20 --=20 2.43.0 From nobody Mon Aug 24 04:17:45 2026 Received: from MW6PR02CU001.outbound.protection.outlook.com (mail-westus2azon11012039.outbound.protection.outlook.com [52.101.48.39]) (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 1369F3BE15E; Sun, 16 Aug 2026 15:49:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.48.39 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786895387; cv=fail; b=X08Gkr1Ahi87kKar0LAtbUg06A4yeblHMRGULPKNB4hwCxAGzt7L3uT1TJ2BOvBXoGh7O80e8fpzWNJh+/s0MS/PsoDVnnK6Viyj+zFp3PwwO192IB0n3YNGYmYIN8jc2boTEDF7ldjmNF15obR9Cll51eWKShDAnCPq850U45E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786895387; c=relaxed/simple; bh=KaZfgW51wL1OOUYVbCzQqdEmid76AtTqxn/a+5dH3UI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=UxVOcnO0MLF+Nd2RJumuZJ7k51gnNSmzXSqbBedrARdZndwtr5HynLFGwADPUwMy8sJYJ/dOjtr8vBeyp4lXOS4cUL7PeGAODerallemqsMfYIaenbRNYsMLpU9HgyVV8Iqdn1RyZS5kEtK+h1mEONzx8o41+fW8cw8cciGV210= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=XuLMU9b9; arc=fail smtp.client-ip=52.101.48.39 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="XuLMU9b9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=flp+WMD4C9cWwtSvecn45gVG2DgtfMMoWoX9bWb9vL/ACWWoxzoIPbiAOl9S8FPA67HceP8rHf+0/oRirEMHwA9+rpJjVY9oMGa2CKnYNmvzdlfJ7LX3T/D7tbgTSWBCXuDrSLH+UDWDPImc18S1FfcRsaungD482+7xwAKG/hMf0cFYuf6IgpzTv8SXKRnsasi1bEwF3H4Y+0V9ZXpOo4MLc+Me872KdS2mFp20XmRPkOmxZLV7rvweFhHeu0edRQMJ8K232qM8FhHPyvA6M4CE6LPDJlf5x1kHuAmjWK1cU3q/pwKBBpRnv/W50ldtwNlWazoEPyHdeImOt6FRkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YS8wQOmMlJglwfw0HbzI1QjskZj4yZZzJ3XU4zwacN8=; b=wX9vqkW83sQrA9cXCV+wevwYO1+WKvag0EbiwRzR4di+lU46Rvn9wwJ4cQbHBh2Gw/8yM+x2kwj5KUZ/NXj/CJeJWfikvgtAmvuI+fUDH7KtkI4cwKngq5OXm2WIsHwF4Jv6wRGfLZI8LEG3hqy0cjCNWZMMg2eebcfIyyDRT/NisKi8pyOuhRb8NZwak+VtSddKBUeRXfYUWLwYaW9WlLgnQcU17T3HFduuDNtzgcpcLXQ7pZssGyUbNk34iJtuyRaQ7Cjpu8z1CyVi8vKfj5ivjezg/+nIa8m60epFeH+1uDAYRlLO+AietO8pOR4JLVxCEvzgXO3uyFkVK92ShA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YS8wQOmMlJglwfw0HbzI1QjskZj4yZZzJ3XU4zwacN8=; b=XuLMU9b9Iwt5smea/3Axs7dmXOWfUZ0BTp/3LK11mOdRxU2gTDtQ6t4gDasqQitYwPr53DAqp6FM5+/lnP7Jrg0d9Gz4NYcUfZujad3tU5ziKKD+BzaWHffpDGuAQsAkkxS7za0Idd3lloXoqBclik+2t5lbU+wttwndvon1vYs= Received: from CH2PR14CA0031.namprd14.prod.outlook.com (2603:10b6:610:56::11) by SA1PR12MB7149.namprd12.prod.outlook.com (2603:10b6:806:29c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.17; Sun, 16 Aug 2026 15:49:42 +0000 Received: from CH1PEPF0000AD7B.namprd04.prod.outlook.com (2603:10b6:610:56:cafe::3c) by CH2PR14CA0031.outlook.office365.com (2603:10b6:610:56::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.17 via Frontend Transport; Sun, 16 Aug 2026 15:49:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH1PEPF0000AD7B.mail.protection.outlook.com (10.167.244.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.3 via Frontend Transport; Sun, 16 Aug 2026 15:49:42 +0000 Received: from [127.0.1.1] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Sun, 16 Aug 2026 10:49:39 -0500 From: Shivank Garg Date: Sun, 16 Aug 2026 15:49:26 +0000 Subject: [PATCH v3 2/3] dmaengine: fix use-after-free in dma_chan_put() and dma_release_channel() 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: quoted-printable Message-ID: <20260816-dmaengine-kref-fix-v3-2-7e76187145df@amd.com> References: <20260816-dmaengine-kref-fix-v3-0-7e76187145df@amd.com> In-Reply-To: <20260816-dmaengine-kref-fix-v3-0-7e76187145df@amd.com> To: Vinod Koul , Frank Li , "Logan Gunthorpe" , Andrew Morton CC: , , , Shivank Garg , Sashiko X-Mailer: b4 0.15-dev-47d62 X-Developer-Signature: v=1; a=ed25519-sha256; t=1786895373; l=2698; i=shivankg@amd.com; s=20260518; h=from:subject:message-id; bh=KaZfgW51wL1OOUYVbCzQqdEmid76AtTqxn/a+5dH3UI=; b=UdeL53r9xNWX4ZTvVZD/dYXUvemfJpST9mQtofIXMbEUBc/RtMu3I/CbGf1dTQTUPBgtyZfn2 3Ld3oOF6V3jA5gfi1usMufp5hK/DgeR3lvQYVvT9Xt1R8MBiuKl55qZ X-Developer-Key: i=shivankg@amd.com; a=ed25519; pk=2l2QGTeXuGkZTtfmx0nPQU8iFZfjYmX/ymMojitevx4= X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD7B:EE_|SA1PR12MB7149:EE_ X-MS-Office365-Filtering-Correlation-Id: f98d16b8-b1a1-4f34-9fbd-08defbadfcbd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|1800799024|82310400026|23010399003|376014|10067099003|56012099006|18002099003|22082099003|11063799006|13003099007; X-Microsoft-Antispam-Message-Info: YAozcXx0ib3wuyD2yUTL7zYhhB5ikfWZrF6XJeMhEoFX2MH6FPPAkhrT5OZdYbazQrK0sa/IAsx8LnObrlxqt514tKBmM6c8urvl7D3DLReGohCEZJt6OyvsGqxNSSW2ih1Cz0NIZ/QbAeddty4cXjMSibQfZv13zaNN6XaSn0dwjEoH5FiFzZrR3uv2vsjs5YHUtTlhh+NemYsDxZFRZzHIaZMa/xT0/GgcDSmg86nKP/nTInuUJOr8/wpoQM93+pBPcpiedIF+QXuEQHnzTRw+yZabEsXPxlHOb+EdXd48zDWMohu1bngQZdph+62eNG0TphPwuT4LGmOB30jdl8XuRDg/FQxhqK2+zf3Ap/foou5NUlV8Ylct4cQGYapg9BYfhi2QuowXrFzfFrgMgkYi0PoSZlYjVCdFbKhcLm3OulUefNkrVd4BiOcif0hL8rkIhqaJ0yhjczO0qXAQJ2U/Q4+3uGvKXoDAmbCQtfj+Q1vjCLdnZA1Fbmpp+4knse9Jxx50RdOLm6wvJiB6u6XBXCDaTLNfgtboz1H3BVTAMsjjicKFIW53vlBUBe87Jk8cWZ7mu0y63s8nEspm+KRYJKC2Qq+E0Tli3/X1UVqnYAmWaDOFI6WzDLNM4+gYAjtWFGtaby7Xj/CXq7TQHg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(1800799024)(82310400026)(23010399003)(376014)(10067099003)(56012099006)(18002099003)(22082099003)(11063799006)(13003099007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: V6I1jsS6BYAOKQEdPwuBU5K322GRNAtnOTzW7hOj3Fq/dFoOv58F6PsbLxC9v9+79OBBH4BdJoS1ixtVG9fUYOYWTYVa6mpL7K0kCbrp/aNlKH5m4KsH+pu7bGRAGymPY59dm9afqB1gFiD3t4csBpwqwmHiXhAn2EdDUuIeHKgxABDaGhyoFfOB/zj3eRMf5BK3tVXNwNTyIm1LFtKOoZdyHSQ8xjxGBK8Yivayrxmp2MRUE7TosVrvxifgr9K8dsMAakBwNZj1nbajSWp4BuM2BKOxZQtbqw0a7/Ex8AQLmHLtLFhRUkgx/5Mc1kILeIO0gGo8hDPW8+mrwtofm4aMsG6JZ2GjNEr2a/3PW3rvW6m+cCgRA7Y7taXbjxXnCDIqC/J7cS1kNpZ1WlUgGIDbv8afCyrF+/+aWbIeb99j21zJBN2XMAexwSJ7Yc8M X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2026 15:49:42.0851 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f98d16b8-b1a1-4f34-9fbd-08defbadfcbd X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD7B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7149 When dma_device_put() drops the last reference on chan->device->ref, dma_device_release() runs and may free the dma_device along with its channels. Two paths still read that memory after the put: - dma_chan_put() reads chan->device->owner via dma_chan_to_owner() for the trailing module_put(). - dma_release_channel() calls dma_chan_put() before reading chan->slave, chan->name, chan->dev and chan->dbg_client_name. KASAN catches the first one: slab-use-after-free in dma_chan_put+0x3e6/0x4c0 Read of size 8 by task insmod/6319 Freed by task 6319: kfree+0x225/0x470 dma_chan_put+0x395/0x4c0 dmaengine_put+0xf8/0x160 Cache the module owner in dma_chan_put() before the put so the trailing module_put() does not need chan->device. In dma_release_channel(), move dma_chan_put() to the end, after every chan/device read. Fixes: 8ad342a86359 ("dmaengine: Add reference counting to dma_device struc= t") Suggested-by: Sashiko Link: https://sashiko.dev/#/patchset/20260518-dmaengine-kref-fix-v1-1-4d612= 5048fb7@amd.com Signed-off-by: Shivank Garg Reviewed-by: Frank Li --- drivers/dma/dmaengine.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 516d6d933208..bf491eb10596 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -495,10 +495,13 @@ static int dma_chan_get(struct dma_chan *chan) */ static void dma_chan_put(struct dma_chan *chan) { + struct module *owner; + /* This channel is not in use, bail out */ if (!chan->client_count) return; =20 + owner =3D dma_chan_to_owner(chan); chan->client_count--; =20 /* This channel is not in use anymore, free it */ @@ -518,7 +521,7 @@ static void dma_chan_put(struct dma_chan *chan) /* This channel is not in use anymore, drop the device ref */ if (!chan->client_count) dma_device_put(chan->device); - module_put(dma_chan_to_owner(chan)); + module_put(owner); } =20 enum dma_status dma_sync_wait(struct dma_chan *chan, dma_cookie_t cookie) @@ -916,8 +919,6 @@ void dma_release_channel(struct dma_chan *chan) if (--chan->device->privatecnt =3D=3D 0) dma_cap_clear(DMA_PRIVATE, chan->device->cap_mask); =20 - dma_chan_put(chan); - if (chan->slave) { sysfs_remove_link(&chan->dev->device.kobj, DMA_SLAVE_NAME); sysfs_remove_link(&chan->slave->kobj, chan->name); @@ -930,6 +931,7 @@ void dma_release_channel(struct dma_chan *chan) kfree(chan->dbg_client_name); chan->dbg_client_name =3D NULL; #endif + dma_chan_put(chan); mutex_unlock(&dma_list_mutex); } EXPORT_SYMBOL_GPL(dma_release_channel); --=20 2.43.0 From nobody Mon Aug 24 04:17:45 2026 Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11012025.outbound.protection.outlook.com [40.107.209.25]) (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 E9CD435A38C; Sun, 16 Aug 2026 15:49:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.209.25 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786895397; cv=fail; b=e+S/X0dyZdfB44WLUTBpe8z33FXn2afyS16jOtdORAWH7NNtara5Ixo4VYJhWixMo63G31V62wG6zJRXUn3knIP0AdPHjHZTdO4x00wdt66iWEMtYJibIsSm9zeVJMtEp6TLmxyvQ4lfrTvxB70bwTHLpJYUrq+PY24on5CsW5U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786895397; c=relaxed/simple; bh=jxiqrS26nswZvJrOzWQ7M3DiiuDTx00kRIcfIiYoFUI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=NinwRlvtFKheZa4+EFSxn1ambdLBLOgQD7m6HSiXYTZ+R/1EGWn6202UeO+aKA9P5i/mdaWuHeg6goq4ZIz7mpPCRhDFTva/NMCyzvSIiCLgn6C5FUtaOEIzSygySu2LccqbediFD609aYWs9caKPrlposOmxt1R5itAhued8Tc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=RaD2ZIL5; arc=fail smtp.client-ip=40.107.209.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="RaD2ZIL5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zD+/fJQX+YM8pxJ1+nFO3RLrvKrg8TgYTEetdowN28AEuHvLJ6efYLytGzSbnviauH1NSE0L7M0uUQ6Sie4A7iWZxXmQl83oFV1U24wX3166+0+Xa1O5EAWH8+3jjl1RHgNSg2H8JS/cXOZ9+cRxs/w7Vr6qWnWryZdGymzzcuqciE4qECACbtoWb26vbNgWk31t9aQsFGaw/4xkC8U2Jy1da74V4avk6rr1d6ETWx3iB1uoZ0X5aQK98BShI6RfeUNzRfELcCoiWHcuqYqULlveUR88MHFAu7bEjhwMhp8i7d37kCC5NZvNdyrxKQFEpqQpq6Vht4nhUzHiTeFewA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+j/8RC/1QOjOmvJ/5FBPVw+5X39jsQAEIkDBQDOwXPQ=; b=YTF92i59MPYjAYE3XsjTluJK5IDRcWeUxn6g3Pm9DQ/rIoo2D/cpVd1mEQtwZ8oI3ptFmp5CxRAPfII+kIcpLAuILO7h3aCEUesW1WWDEisN9m85QPW17Mm7rj0ZtVdjLjJeprEgMQNFdU8AKN6c2fi7fCFpHyi2rmyKaY1alSfPShZaj0iMbHQuxjfG7LOGz+g29yX8PeByNXGYKqehaQDFPTk+zpsoRJrPgAupobrxte+2E4AcdexgoAJxQTD3gyzEEDZqJbe1g9mo4ANxGhW8intOj+6WVSk4jCkINlHiogUk4MEMdFuvD9SxGXZufQyMTGJOzzW5s2WYpNFuoQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+j/8RC/1QOjOmvJ/5FBPVw+5X39jsQAEIkDBQDOwXPQ=; b=RaD2ZIL58pY8Ik0hb2cfGiAVx3IrZInE1tHPPLjOsV7XyHrFoiM3PdFaEY/L9lvssn7yaawzw9p0tuP71z/8kACy25+BPwMPZTuEa1vHjKTH5RmrpK10o2fPRO4F5JIow6oXxhd8vw/6g64T2N4UvAGIljCLExRrcGrhMbE4fA8= Received: from CH2PR19CA0010.namprd19.prod.outlook.com (2603:10b6:610:4d::20) by SJ0PR12MB5662.namprd12.prod.outlook.com (2603:10b6:a03:429::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.17; Sun, 16 Aug 2026 15:49:45 +0000 Received: from CH1PEPF0000AD78.namprd04.prod.outlook.com (2603:10b6:610:4d:cafe::c) by CH2PR19CA0010.outlook.office365.com (2603:10b6:610:4d::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.315.17 via Frontend Transport; Sun, 16 Aug 2026 15:49:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH1PEPF0000AD78.mail.protection.outlook.com (10.167.244.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.3 via Frontend Transport; Sun, 16 Aug 2026 15:49:44 +0000 Received: from [127.0.1.1] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Sun, 16 Aug 2026 10:49:42 -0500 From: Shivank Garg Date: Sun, 16 Aug 2026 15:49:27 +0000 Subject: [PATCH v3 3/3] dmaengine: wait for RCU readers before releasing dma_device 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: quoted-printable Message-ID: <20260816-dmaengine-kref-fix-v3-3-7e76187145df@amd.com> References: <20260816-dmaengine-kref-fix-v3-0-7e76187145df@amd.com> In-Reply-To: <20260816-dmaengine-kref-fix-v3-0-7e76187145df@amd.com> To: Vinod Koul , Frank Li , "Logan Gunthorpe" , Andrew Morton CC: , , , Shivank Garg , Sashiko X-Mailer: b4 0.15-dev-47d62 X-Developer-Signature: v=1; a=ed25519-sha256; t=1786895373; l=2066; i=shivankg@amd.com; s=20260518; h=from:subject:message-id; bh=jxiqrS26nswZvJrOzWQ7M3DiiuDTx00kRIcfIiYoFUI=; b=/uuSh1RH1PDp9cMe4PWWLC4i4eMMKTPkz40gBC886+brLf54A7amVji4RaYZuTclD4rLkDmtU V76zdRHu3cuB/J/Sb4nypHrJq+ZY1pizk31kdmlPVSLrv7Q/1A/ATUJ X-Developer-Key: i=shivankg@amd.com; a=ed25519; pk=2l2QGTeXuGkZTtfmx0nPQU8iFZfjYmX/ymMojitevx4= X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD78:EE_|SJ0PR12MB5662:EE_ X-MS-Office365-Filtering-Correlation-Id: 9289b9d5-3c41-4284-b15d-08defbadfe64 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|23010399003|1800799024|376014|82310400026|13003099007|10067099003|11063799006|56012099006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: BPRKIJRUhnhYFLlAP/BAW6UWznHoXTc37T/+JP6BNs5FbzU9qfi+gsbvDx8jfAZ2kOfxY9UrJIIe3InIJnMkGUe8mBfPaUjh8Gf6p6l6ZKpjQQ9ft8P7riVbrMbFd71+jwzstfxFxbBlVz1LlDmiU54UEncjqleKIgx9+A8dJ6pTAYYZL7MbmHwAVAhLQ67H3HaHyDSfZDXsWbxDV30UzxW9RjySJYcYozT7b+du71ygSf18anPIMfqVVdmlUHBkucUYB1jH+Q3wXuOuu0ZeZI/czWJDRc9r+ZLP4zVsjwLZon/kNUYk56uslHZk3lAuKvHn99wW8NCHLUKCYU9Jp/WFVtxF+dBXZYqSz8R+kTphfcq8OOmBBgV16oMshKA2v4QM/c4R5+DcTH6Gg+beUQmYMCPbIqs6p1bqP2ydCZytHnW4EozUKtnidMSIdl4bZsaSZOjcssTCXo2BcREOwGAgwDRPfCckFffrDA3Ly1/NJROkqSp3Y+yE3t6srYHMYSwlQP7r8Bqz1BXHV5LB3+ni2TdSSChDn2SCYqPks5P05eikblIEzzYwzqb3Tie0m+NdHNODL9QMaFb/x48PAiF92hkg3PLnO1gT2L/OHfnCt9L2QZJGg+E2SdvPqFpFAIuyUs1PSI5rXxjfzBpDXQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(23010399003)(1800799024)(376014)(82310400026)(13003099007)(10067099003)(11063799006)(56012099006)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7sHZt1VHiPqXaZon9jt/800L20+HQmOZdWnU3n0vh80S/+8yDtGmyWLd1a+aQ2OuCimRyurejlzEqg7PbCxYv/n22vwD9j4NrqcDkOjmJrnpqJN6apwJma3C4L+JZu2nMCHiDwMSxdmsjVTNHFtnnHk9QYEimy6pU6WfSjRI39d5H6U4h9igwZJQyObHNmh5y/FoL/i+eQQ5LQpbmtfqVrF3uKtPvosuawjpMu3nBGj7m0oCM/mgp/XaXws3u40tQfHFVpHjlPRDPysSQlbmPZJdSBNBqotrh5JjIwdTilsHJZaUYbZogIVMFfY8nOV5ihto+xiZBvOuo9kjtTdQi12Sg43pe87mJKf7i2qXckueUwycbdWgnlYQuwPeIlIXFTP4E4G/PQOYpnNrk8RiVWIqGc0ukdOILLV0olGA/DZ1g1YbuWBEr9a/quyxIxxG X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2026 15:49:44.8568 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9289b9d5-3c41-4284-b15d-08defbadfe64 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD78.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5662 dma_issue_pending_all() walks the dma_device_list with list_for_each_entry_rcu() under rcu_read_lock(). dma_device_release() unlinks the device with list_del_rcu() and then calls device->device_release() (which in many drivers, such as plx_dma.c, directly calls kfree()). Because there is no grace period between unlinking the device and freeing it, concurrent RCU readers in dma_issue_pending_all() can access the device after it has been freed. The lockless walk originally relied on clients holding a dmaengine reference to pin the provider module, and therefore the device, for as long as they might traverse the list. Commit 8ad342a86359 ("dmaengine: Add reference counting to dma_device struct") decoupled the dma_device lifetime from the module reference, so the device can now be released while a reader is still walking the list. Add synchronize_rcu() before the device is freed, so RCU readers are guaranteed to have finished. Keep it unconditional: providers that do not implement device_release() free the device themselves once dma_async_device_unregister() returns, so they need the same grace period. Fixes: 2ba05622b8b1 ("dmaengine: provide a common 'issue_pending_all' imple= mentation") Suggested-by: Sashiko Link: https://sashiko.dev/#/patchset/20260526-dmaengine-kref-fix-v2-0-3df60= afac01d@amd.com Signed-off-by: Shivank Garg Reviewed-by: Frank Li --- drivers/dma/dmaengine.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index bf491eb10596..29b128aa0bea 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -429,6 +429,12 @@ static void dma_device_release(struct kref *ref) list_del_rcu(&device->global_node); dma_channel_rebalance(); =20 + /* + * Wait for RCU readers (e.g. dma_issue_pending_all()) that may still + * be traversing dma_device_list before the device is freed. + */ + synchronize_rcu(); + if (device->device_release) device->device_release(device); } --=20 2.43.0