From nobody Mon Sep 28 23:07:50 2026 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB507397AEF for ; Sat, 15 Aug 2026 15:17:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786807050; cv=none; b=iOsArgoMYmw7KXrEVfYshomtp4dmH4oMFnhkt5im2Por8CE/AKfeTJyqQa9THThuwwIuywVD3Vnggts5RbUkBqUvnqWmdqjeJSvXpAE4V9b2KdClonE4WCcmyPWUKAkU6pbL729XcdX76t7l+HKAQkK0tWN17aibuYvSldzAC5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786807050; c=relaxed/simple; bh=L2rv/8hWgLO/9YX6ozCUc2a/DuHG5ngeE3Pn+3OXH8Y=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pWHJZz9nAozjkSsLuxmzt+Gvo/exhQQv5loDTjrNYkSRxPuw2sSlE+7ZK+Q4Hflcr2zh9wjmgtSDtksikwWgeRew7W6sPEOc4Y7GXMWQUgfquEOz7EDUdeLn60ZiohlY1S4qWjb6cQoq/Z53JitGIYQ1ReNiFLOxHf7pXnvUk10= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=oascWz5K; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oascWz5K" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2caced6038eso22631455ad.0 for ; Sat, 15 Aug 2026 08:17:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786807048; x=1787411848; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=UM/qY+57O2WGKIidD8uuvpNNv07GGWbHqFgymg7+PkQ=; b=oascWz5KL4PyzIZbFGE5GK3I3uLIfdIHeWGEmXFuRsm48rrpO+tWiH7aaOkWJp+Qh+ WhnHuVhcwP4OZTTRjX4i2z8dcG9UDvqQjX07bGMc0wbP1NXcCM04ziUxhi6IF05uwDck LN+4sbEdD4JGPCsnMExtgwTHip2daVL6HZszeTMQ+RW3G4d595IqYkhgjnpjtS7DZSWg gnRwR2maVnBLwAXUjMU025WyoBgJy3wKGiHeeTLlvH9ta6I0+SeL9RSP3PGbNrJee28W /jlL5kpgiEerhzg/udjPT2GjzD1vm0JScUAKzGrx2AAFot4vy1RG3GdxaJG1mqcpefs3 hbjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786807048; x=1787411848; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=UM/qY+57O2WGKIidD8uuvpNNv07GGWbHqFgymg7+PkQ=; b=YcV6tKYQEIkNSLWXhGsJAcg7wRfDwABh7MQDPfx+EpN6R0vZHykOtkuQLXal6CC8xl e3WGBbT7MSRgehEdfizSClfxpXTt6l8pFuAC939ZcjkRpwLPPbTM9LRS/QXgbhR1TR3q vfpigjw3SdrMOZlY/v2Tpvdd6bi0W016LIc3stRNkLZ9iDrSjISITK66zbPlmzJGZFOj jtel82W6c1YDhSCdUYce5VPsWKUN77oJy4A/C+XSwoY7jX85UJgo7CFruRCUbTefKKDw hso2cXBW/1EX3M/amICnE86DTUrkUg8jaerAl05lJbf8fge5jP5S8EHftvO7qH858Z0Q PAhw== X-Forwarded-Encrypted: i=1; AHgh+Roox/YBwNgA/f6xUUNJcog8y6/f8UbGCAOQwEwEzHQnI6SpVi4aMfvEM8Qmg7lQg5w1na+0CSj6wqf/nV4=@vger.kernel.org X-Gm-Message-State: AOJu0YzCfK+EL2YM4pCkiapQnsCuP+W2EhR8CC9/Eu2menjoK7t0iE4z FLqL9r+skRX/8rLPf5uqGVqZVYGqfQgIQean4zk4jMtjrBXgeojmpoDi X-Gm-Gg: AR+sD11gMPZ9EqSGpBI5rBrPy0neM9RO3KRf8ue4IlmGGPFkLHy9paZ2fvsN+UXe9pE g1i9D8XTjuPUt7J8AEUp87OixX4O1lPwsqbIdbRSt+r+MhKBigjRLAMAVS/s1d5BRHM84WGNXSM HMRKV26VA7fdU5cVpewCMlY0KBaXE4fWkEKHuRzYEkd2keyM82+raXZAoWjMA15Zv1r2vrKKMMC mKb6/6+BA+aSbTFSw6+M2zVEZNiYi7lCWivTZ7TypafLw9PB3AFexQmGseamg3USVuP9h7IEhug 0QGCPqLKBVS7j5n6KcfQFFukV3NgowPRekRm2gQyvhd0gyxI5QhzFGpedo8tGR2/gQ1Gfnpz1oT fT7ay7PfW4ZoXOtUFgoWvW7lruzOkIztl2ev6LRp3QfQ2zlLGa1MVzifMjoMQbx6y88et9u6N2V 8dlngLyw3tvMoNc9MK3YUg9D88Oh/g+6FxR842//kXGH+jLpJ/S6HGCUt2eo2Tuu3RNpRFm4XvH zrgi7W6KA== X-Received: by 2002:a17:903:15c3:b0:2cf:b9f9:18bb with SMTP id d9443c01a7336-2d3afdacabfmr116123305ad.4.1786807047906; Sat, 15 Aug 2026 08:17:27 -0700 (PDT) Received: from haichao.tail057a43.ts.net ([2001:da8:e000:1206:5225:2a2e:8e7c:13a7]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d3aeb88bddsm19887805ad.63.2026.08.15.08.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Aug 2026 08:17:26 -0700 (PDT) From: Ruoyu Wang To: Andi Shyti , Frank Li , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Marek Vasut , Wolfram Sang Cc: linux-i2c@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Ruoyu Wang Subject: [PATCH v2] i2c: mxs: fix DMA channel leak on probe error Date: Sat, 15 Aug 2026 23:17:20 +0800 Message-ID: <20260815151720.3757460-1-ruoyuw560@gmail.com> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" mxs_i2c_probe() requests an exclusive DMA channel before resetting the controller and registering the I2C adapter. If either later operation fails, probe returns without releasing the channel because the remove callback is not invoked after a failed probe. Use devm_dma_request_chan() so the device core releases the channel on probe failure and driver detach. Remove the manual release from the remove callback because the channel is now device-managed. This issue was found by a static analysis checker and confirmed by manual source review. Fixes: 62885f59a261 ("MXS: Implement DMA support into mxs-i2c") Assisted-by: unnamed:claude-opus-4.8 typestate Signed-off-by: Ruoyu Wang Reviewed-by: Frank Li --- Changes in v2: - Use devm_dma_request_chan() instead of explicit error unwinding. - Remove the now-redundant manual release in remove(). - Add the Assisted-by tag. v1: https://lore.kernel.org/r/20260814134033.1386874-1-ruoyuw560@gmail.com/ --- drivers/i2c/busses/i2c-mxs.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c index 4e07babea9c3f4..eee4fdcd9df31a 100644 --- a/drivers/i2c/busses/i2c-mxs.c +++ b/drivers/i2c/busses/i2c-mxs.c @@ -839,7 +839,7 @@ static int mxs_i2c_probe(struct platform_device *pdev) } =20 /* Setup the DMA */ - i2c->dmach =3D dma_request_chan(dev, "rx-tx"); + i2c->dmach =3D devm_dma_request_chan(dev, "rx-tx"); if (IS_ERR(i2c->dmach)) { return dev_err_probe(dev, PTR_ERR(i2c->dmach), "Failed to request dma\n"); @@ -877,9 +877,6 @@ static void mxs_i2c_remove(struct platform_device *pdev) =20 i2c_del_adapter(&i2c->adapter); =20 - if (i2c->dmach) - dma_release_channel(i2c->dmach); - writel(MXS_I2C_CTRL0_SFTRST, i2c->regs + MXS_I2C_CTRL0_SET); } =20 --=20 2.51.0