From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380294; b=emEwpdKMCWcnpnVduA6Jb3O8rb1YrctNfZPWeRyilubV/YaUNVn/aElIGaUkt4AUMcUT qeNOCRxywmuuN7OC9sOKhOKomdjsl5r2K+aTdmd1f+46ArAXd+NMH3I14LEi9BmnmqJh9 DFDrhJOSIiz2dsOa9+J3ssOIzPdMDJvKv4TQ2e4y9PNhdQqOkknYwaDCOa9j3pe5WumD2 91llYILr0tJQ46gh6HskJw06FsWpOAUcEs6PELGIDGsOeJhRvz593l6CtFrOj9babe4BN JJTZJ/plvJYUU+yalFdrTuqRBp78hQb4ux4Nl6C8wzV9pdOUIzUVRy6pJCiCRLDAciQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380294; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=MTzzM3zfWgTKdMad2JWpNpSzghUWJr0UcfWJJCrCSQ4=; b=FPrMFnW12nVCg6Dc3UcLb5pVXwpxckzzV8rqd1Um+FUnKxkPzgfWD0UFxmZbv4lxZSSM 8R0QqbwMHQmzYT2660CpkupS9njZyGitJqXremjQDg3k2qco7soMPLjLGByeDc5+1zOJe eMoCHD5RH0FLTwlWGu22f010MDww4cpXBdzMgD2thXSOU6/B5dXfhT4HkBB6hKDzaYMlF yO1KR47ek/D8nnxP+wDF/RXQRDMhNwMCcQsSHA1a6CMLsy19dVcBMVXrMdob7f3cbwT3O iHx21n9hdw2QVCtj/t1QxM4qFmZiTBptX/2eNx4dPkaZ6a2r7Z4ARLfJ4rUW7e51jsw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Md+oGEIs; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60E23606A689; Fri, 4 Dec 2026 10:31:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Md+oGEIs Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC03B1F0092C; Fri, 4 Dec 2026 10:31:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380294; bh=MTzzM3zfWgTKdMad2JWpNpSzghUWJr0UcfWJJCrCSQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Md+oGEIsvMhs+n58nBMybBJVt19HwSVSH/rDm5HFsdTxsSejABeJhJU2hwtkc74K3 HYWeL+iMWxRweO7+OmtnzJOpf123CQDMi1X8qUxsWTwBxWYoRozk/NMbe7Jj+FE7dz j60ZzdJzH4oMcyr/qN2tsYCC8qz1UAK3s9DZqOtA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Stefan Ghetu , Shengjiu Wang , Mark Brown , Sasha Levin Subject: [PATCH 7.3 210/742] ASoC: fsl_asrc_dma: release DMA channels on repeated hw_params Date: Fri, 4 Dec 2026 19:01:14 +0900 Message-ID: <20261204100640.659845097@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stefan Ghetu [ Upstream commit 0d02516a94b47637acaad8e7a83c3a810402e70a ] fsl_asrc_dma_hw_params() requests new DMA channels on every call and overwrites the previous ones, which are leaked when hw_params() is called again without hw_free(). Its Back-End error path also releases a channel without clearing the pointer, so the following hw_free() releases it a second time. Release the channels of a previous call first, and clear the pointer in the error path. Fixes: 3117bb3109dc ("ASoC: fsl_asrc: Add ASRC ASoC CPU DAI and platform drivers") Fixes: 36124fb19f1a ("ASoC: fsl_asrc_dma: Fix dma_chan leak when config DMA channel failed") Signed-off-by: Stefan Ghetu Reviewed-by: Shengjiu Wang Link: https://patch.msgid.link/20261116093751.138455-4-stefan.ghetu@nxp.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/fsl/fsl_asrc_dma.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c index 0aa5db8973d6f..7615bef3b9503 100644 --- a/sound/soc/fsl/fsl_asrc_dma.c +++ b/sound/soc/fsl/fsl_asrc_dma.c @@ -124,6 +124,19 @@ static int fsl_asrc_dma_trigger(struct snd_soc_component *component, return 0; } +static void fsl_asrc_dma_release_chans(struct fsl_asrc_pair *pair, u8 dir) +{ + if (pair->dma_chan[!dir]) + dma_release_channel(pair->dma_chan[!dir]); + + /* release dev_to_dev chan if we aren't reusing the Back-End one */ + if (pair->dma_chan[dir] && pair->req_dma_chan) + dma_release_channel(pair->dma_chan[dir]); + + pair->dma_chan[!dir] = NULL; + pair->dma_chan[dir] = NULL; +} + static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) @@ -190,6 +203,9 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, dma_params_fe->addr = asrc->paddr + asrc->get_fifo_addr(!dir, index); dma_params_fe->maxburst = dma_params_be->maxburst; + /* hw_params() may be called again without hw_free() in between */ + fsl_asrc_dma_release_chans(pair, dir); + tmp_chan = asrc->get_dma_channel(pair, !dir); if (IS_ERR(tmp_chan)) { dev_err(dev, "failed to request DMA channel\n"); @@ -342,6 +358,7 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, dev_err(dev, "failed to config DMA channel for Back-End\n"); if (pair->req_dma_chan) dma_release_channel(pair->dma_chan[dir]); + pair->dma_chan[dir] = NULL; return ret; } @@ -356,15 +373,7 @@ static int fsl_asrc_dma_hw_free(struct snd_soc_component *component, struct fsl_asrc_pair *pair = runtime->private_data; u8 dir = tx ? OUT : IN; - if (pair->dma_chan[!dir]) - dma_release_channel(pair->dma_chan[!dir]); - - /* release dev_to_dev chan if we aren't reusing the Back-End one */ - if (pair->dma_chan[dir] && pair->req_dma_chan) - dma_release_channel(pair->dma_chan[dir]); - - pair->dma_chan[!dir] = NULL; - pair->dma_chan[dir] = NULL; + fsl_asrc_dma_release_chans(pair, dir); return 0; } -- 2.53.0