From nobody Tue Dec 2 03:02:38 2025 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 3816F2C3255; Mon, 17 Nov 2025 16:13: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=1763396005; cv=none; b=QvUFW7R8Mu/Hzt2IjlCdHoL6SgAY3loGU/Fc8bclpdfT56aTY2n6/bsDbpm15SWqEqszl1EEHHu2lIWCOO+/3D763AMO8nrWTBnbNag70b/wnkyGNpjJQPjSukTcckdJd95oSGhfhfLRwu3wT8oAr/yIeawQRvFkhY1slUjiJLU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763396005; c=relaxed/simple; bh=VBdlt/U82+VSKcAFX8Y5c0YN3goi7irfhq7BlBASkaY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u1HYESuQjQeynOy31aTwRKZpHGCIZXEoO9PmxyWhtiD1IcHdx0gN/A1DZG8O9bCjvBcNDsCjgP2T0LeDsMzojUB5ncs3ueDlSkgTaXmNPhIclt9fF5C27Q4icz3eNH4LSjgcRTSCAwz118McOONiIBvaYD1XukRUu1P9hTVI5FE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sXx6BYgO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sXx6BYgO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7ABAC19425; Mon, 17 Nov 2025 16:13:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763396005; bh=VBdlt/U82+VSKcAFX8Y5c0YN3goi7irfhq7BlBASkaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sXx6BYgO8wlWV+HuayrfP9NQyPgF1ynggGKCfEPzsPa0uMlExf8FO1qMTvriuNC3X Mou9CC8QbfBGNx7NnnlBaNaa059D6ktxowiGOMhY9HQ631O38fnhGm2LbDqBffyrSs b7VdUZY3wijCqcBcsbULbhQs6MPHylANLXn6X2iCpmD5K6TeNMO+zJlMAIyosYkstc 4vJaCRVlUGZSDnaf8cJ75nxpPMOKMZWXJ9rfcdmGB3eF19WETT+gJ2wV0wPVe74lXM PkiWKsDNtSYuW4fcrAoFL9ZTTM810lxVFARAbckj8RIJsBLgI/5avfWp9T2QlrMXk1 fmvHBCibiUQdA== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1vL1r0-000000002nv-3ukB; Mon, 17 Nov 2025 17:13:22 +0100 From: Johan Hovold To: Vinod Koul Cc: Ludovic Desroches , Viresh Kumar , Andy Shevchenko , Vinicius Costa Gomes , Dave Jiang , Vladimir Zapolskiy , Piotr Wojtaszczyk , =?UTF-8?q?Am=C3=A9lie=20Delaunay?= , Maxime Coquelin , Alexandre Torgue , Peter Ujfalusi , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH 07/15] dmaengine: lpc32xx-dmamux: fix device leak on route allocation Date: Mon, 17 Nov 2025 17:12:50 +0100 Message-ID: <20251117161258.10679-9-johan@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251117161258.10679-1-johan@kernel.org> References: <20251117161258.10679-1-johan@kernel.org> 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" Make sure to drop the reference taken when looking up the DMA mux platform device during route allocation. Note that holding a reference to a device does not prevent its driver data from going away so there is no point in keeping the reference. Fixes: 5d318b595982 ("dmaengine: Add dma router for pl08x in LPC32XX SoC") Cc: stable@vger.kernel.org # 6.12 Cc: Piotr Wojtaszczyk Signed-off-by: Johan Hovold Reviewed-by: Vladimir Zapolskiy --- drivers/dma/lpc32xx-dmamux.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/dma/lpc32xx-dmamux.c b/drivers/dma/lpc32xx-dmamux.c index 351d7e23e615..33be714740dd 100644 --- a/drivers/dma/lpc32xx-dmamux.c +++ b/drivers/dma/lpc32xx-dmamux.c @@ -95,11 +95,12 @@ static void *lpc32xx_dmamux_reserve(struct of_phandle_a= rgs *dma_spec, struct lpc32xx_dmamux_data *dmamux =3D platform_get_drvdata(pdev); unsigned long flags; struct lpc32xx_dmamux *mux =3D NULL; + int ret =3D -EINVAL; int i; =20 if (dma_spec->args_count !=3D 3) { dev_err(&pdev->dev, "invalid number of dma mux args\n"); - return ERR_PTR(-EINVAL); + goto err_put_pdev; } =20 for (i =3D 0; i < ARRAY_SIZE(lpc32xx_muxes); i++) { @@ -111,20 +112,20 @@ static void *lpc32xx_dmamux_reserve(struct of_phandle= _args *dma_spec, if (!mux) { dev_err(&pdev->dev, "invalid mux request number: %d\n", dma_spec->args[0]); - return ERR_PTR(-EINVAL); + goto err_put_pdev; } =20 if (dma_spec->args[2] > 1) { dev_err(&pdev->dev, "invalid dma mux value: %d\n", dma_spec->args[1]); - return ERR_PTR(-EINVAL); + goto err_put_pdev; } =20 /* The of_node_put() will be done in the core for the node */ dma_spec->np =3D of_parse_phandle(ofdma->of_node, "dma-masters", 0); if (!dma_spec->np) { dev_err(&pdev->dev, "can't get dma master\n"); - return ERR_PTR(-EINVAL); + goto err_put_pdev; } =20 spin_lock_irqsave(&dmamux->lock, flags); @@ -133,7 +134,8 @@ static void *lpc32xx_dmamux_reserve(struct of_phandle_a= rgs *dma_spec, dev_err(dev, "dma request signal %d busy, routed to %s\n", mux->signal, mux->muxval ? mux->name_sel1 : mux->name_sel1); of_node_put(dma_spec->np); - return ERR_PTR(-EBUSY); + ret =3D -EBUSY; + goto err_put_pdev; } =20 mux->busy =3D true; @@ -148,7 +150,14 @@ static void *lpc32xx_dmamux_reserve(struct of_phandle_= args *dma_spec, dev_dbg(dev, "dma request signal %d routed to %s\n", mux->signal, mux->muxval ? mux->name_sel1 : mux->name_sel1); =20 + put_device(&pdev->dev); + return mux; + +err_put_pdev: + put_device(&pdev->dev); + + return ERR_PTR(ret); } =20 static int lpc32xx_dmamux_probe(struct platform_device *pdev) --=20 2.51.0