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=1796383508; b=cn1+wZNNtXs4Dikw4sfQqoO1eJJ21wLUjBB+Gz7A2uaDGaIDR+nnxSJvKg0wAfvOqPUK tIk3SRycS+Whl4U8EmCRNjcJPQ0k1mQOmoFDZJehEy9EC7b3sI85q79+Gly0bohj6OtSn rKX3wFelFW/1YjUaYGjACXsOIq8bS2G1ukmIxPkUnKcBeAfAprqVNahQtjJuFCLmrBTda FinaKc30aUdBrL6OfIXAaeFmhrTM8ooMqBzYYpHG3S/61RoOut4y5xkD0B/3Ad+LFB1n4 72JstaK1RKH6UlsfYX0nvZBbLQVhn4zbnhLC2tGJaD5gfWeY/IFdT3QabnrjYsz8YrA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383508; 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=OguuLjm8ItxTiuIKz20lZuuzPySlF/a/48AZ8KU+I4Q=; b=cUT/JtIDm88zef/HncL/v2BpWVM9dMlKWnyFoZpECE3bkBuq5+ZmevCiAriOQpTZ4KvH z3BaEhwVHApuUWtinXfzath1mgOmpbxzMi5PZ9YHldetNPmazPd2rdwCZXGZcy+/2Uhd9 cdKRPCu1tDWg6VE/o/aWwu5H/KB+4x87PuiLa5X7npIdGgNQEOyEbGV0SjFsVqvXXOUar tWaPcqxN8G6wLJ8F5TfoaMGMNpwYfKqJtIz6Vfb4NgxYlKh6zH5hclNq951PEmGDXADIN KsgEzByZkO49rReneC9D/oDsu9W+7JwNq/gJEgnFPz1W7qQiDnVt1ZjPUqdHrGHoVHw== 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=z6yU09qE; 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 85407606A322; Fri, 4 Dec 2026 11:25:08 +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=z6yU09qE Received: by smtp.kernel.org (Postfix) with ESMTPSA id 024411F000C2; Fri, 4 Dec 2026 11:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383508; bh=OguuLjm8ItxTiuIKz20lZuuzPySlF/a/48AZ8KU+I4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=z6yU09qEdYs7tzxB63wyVtJZBdLk6Yi/F84mdvLtX8E2YAcuoMgOCvd1uDNDa3avx mjfDS5JGOPSfTadfd5V8QBSSn5LJV6TbdM7F8CM9ZSx4XqNG1UgPdNbOnGp/2Ic/19 jEM+ON78fYkC27X4e9qWA6Zdr5KQjhOubeyighEw= 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 6.12 252/555] ASoC: fsl_easrc: fix context ownership on repeated hw_params Date: Fri, 4 Dec 2026 19:04:55 +0900 Message-ID: <20261204100618.748627161@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stefan Ghetu [ Upstream commit f50dfefe6d4dd8cf5e826353de21228b9f073e68 ] hw_params() can be called again without hw_free() in between. fsl_easrc_hw_params() then requests a second context while the stream still owns the first one, which is never released. After close, that easrc->pair[] entry points to freed memory and is dereferenced by fsl_easrc_runtime_resume() on the next open. The EASRC slots depend on the number of channels, so release the owned context before requesting a new one, and make fsl_easrc_release_context() ignore a context it does not own. Fixes: 955ac624058f ("ASoC: fsl_easrc: Add EASRC ASoC CPU DAI drivers") Signed-off-by: Stefan Ghetu Reviewed-by: Shengjiu Wang Link: https://patch.msgid.link/20261116093751.138455-5-stefan.ghetu@nxp.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/fsl/fsl_easrc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sound/soc/fsl/fsl_easrc.c b/sound/soc/fsl/fsl_easrc.c index e4079e154202c..351a165e240d6 100644 --- a/sound/soc/fsl/fsl_easrc.c +++ b/sound/soc/fsl/fsl_easrc.c @@ -1353,6 +1353,10 @@ static void fsl_easrc_release_context(struct fsl_asrc_pair *ctx) spin_lock_irqsave(&easrc->lock, lock_flags); + /* Nothing to release if the context is not owned by @ctx */ + if (easrc->pair[ctx->index] != ctx) + return; + fsl_easrc_release_slot(easrc, ctx->index); easrc->channel_avail += ctx->channels; @@ -1508,6 +1512,12 @@ static int fsl_easrc_hw_params(struct snd_pcm_substream *substream, snd_pcm_format_t format = params_format(params); int ret; + /* hw_params() may be called again without hw_free() in between */ + if (ctx_priv->ctx_streams & BIT(substream->stream)) { + ctx_priv->ctx_streams &= ~BIT(substream->stream); + fsl_easrc_release_context(ctx); + } + ret = fsl_easrc_request_context(channels, ctx); if (ret) { dev_err(dev, "failed to request context\n"); -- 2.53.0