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=1796386487; b=gm1x/IkbF78W3B1wcjfVFSHrgSNh1rxVLPnRBwAvDtmPLDOT35ozIwjlRLEM3vRW8BML BMcc4I4XClS5vBiBTg2AYd90tcJoOIIfdF6ZXBuiYbAssFZghwTrTm+H4udVOTMa54hLu hkNAKdzKEybILz10Jk6tzAg+WnDKa5+rXKUhD3UpALGQo378F+UugyTvSt+zsDTEs5muF 7yMQxJTJeP94CzEoe27wiSKvCWopE6+NTJwBgeQ1mpX9d2q9HBpH1Iij8TJwqcHf+cd2G 178eDyegQZXmJnYAh43znMmjPMU39DMWU9d8XxKb65Yue7L1J/WHj3v9NkQX8WoVeYQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386487; 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=84eXDlYEootDU/e98uflpcWp77KzTCRLK6vlI9gHGc4=; b=Wd7LlFvNrSQNtNJSJ8hOR/u1i7UEyin2f+KsrykB+77/ZIFw7ilSYpWDP3ZMlZHeYhnE V01Q2K8HODOzgLBtaDnO9Gx494sM+uMoHGqWpFe27clTmGjY6m/0RU2nayu7ME1SUC8I6 LK0AxGF4YV/s0JR098d124ICb313a4mOkIyaWtldh3I0bqVHBE5xiT/uk09KDmhbrYult 3VvfLXGqtDcrheInD8XmNGxVif//o0XxNliG0If3OFc2hzm2n9s03KqOdqkzkNpXhmAVb ol+L9xdvaAYttzqq5mCwdxuUk+qUm8XPXbS5ZOK6fdwMrvpyMnzmJNAXaUoJ+uaPEOQ== 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=bAIObL8z; 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 4EE6F606A322; Fri, 4 Dec 2026 12:14:47 +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=bAIObL8z Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC7D51F00935; Fri, 4 Dec 2026 12:14:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386487; bh=84eXDlYEootDU/e98uflpcWp77KzTCRLK6vlI9gHGc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bAIObL8z+9RJyrG8pkyQ8yZInF03lx577op2cFTcmr6pVqvjyHI+BHabM6izJaL9c GfsWDoXhE6QPZqd+lZ4ifgHBXDNjS2Z6Z7XRxYgplQMzFXD/Rw/Qt4knpuKLVJmyqL gmfiYMbaoDMhGZwJlezMWVjp26W1NGkzpALYZca8= 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.6 0943/1167] ASoC: fsl_easrc: fix context ownership on repeated hw_params Date: Fri, 4 Dec 2026 19:06:10 +0900 Message-ID: <20261204100726.752431840@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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 16aa0063aa65c..9fc67b1e79f04 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