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=1795937852; b=EIcg77xdkkehO8RnRyzUt16nLZImn+yg2kVGURyj4+R3pLRiHXH9ajRfDbvN1U5CNvgo 7pu6nctfyp8S7e96KkFpdg0aUrylD3lNybjj+jiylrRZkkbafI7Lh7bC5GwoIxa0W9/vM NP1lqWx/sNWHJQpZmOq59eh6q3UctVv7mq9SxPURxY6PNwfSchGCyC7OzNMJFEyN+MZBk NfTwf/ZKV0+UH8ByRHr+mFeOn6LuXuq26KBbUPM/CvfMjoHjQlJMY+TS5Fukslv4zUu4G MsB4boCYEaq6bqG7R8QUYrEuHg1+8+5EunYy5zh91GtYREAZaH9HuhtC57K3GW2FutA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795937852; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=CxzfO0gjZ+TT8VKKZDReq4/eu6lqI1viLko3EFi2dQM=; b=vXZYlTPOMKAtayt7Lr0dkUEnfsMZ8hGAzcK5BYgAKnmvjbawmdN4dW90X5zcwI4mpbk+ F5Qje8LSZGmA/SNmA9KwbRXVrwxxgNUtGond6+V6JykIXwhJYKHYUeETI4Xt9jeOo8QyG m5S3hv5kHk8SWiW6cV+/KvyYc7E8ResDBNENLDq9TYycmOuywhJsY1/bcTmXZ8T2dFyr8 HsF2rsqtnL316u5JyGp7QfPyB3NwtmWV8pFP69swQZbf/IWhGNMyXrfRcFQvIKKPTiM8M +XhpIK7QVeZg2aW1e9j41L3RHtJ5gbiyUWEoju7svr1X2n7/nFBhqBHPQncgtMZQKUA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BrPw5BQm; 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 91CBF606A339; Sun, 29 Nov 2026 07:37:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BrPw5BQm Received: by smtp.kernel.org (Postfix) with ESMTPSA id F198D1F00897; Sun, 29 Nov 2026 07:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795937852; bh=CxzfO0gjZ+TT8VKKZDReq4/eu6lqI1viLko3EFi2dQM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=BrPw5BQmATlYSzVh52jDRopY0DKNeupVDtm6mXRx2rLjnU+CTVEOujq/eaQ38GpUa ZpitCCYeBQgCTGQBWpzEfN+bWXMKFOPt3n4ankdyYDp6l4e94tGAz5vjx3zPZ5Qn8J 0SHKAbC9f9QDuXF/KoK26GH2PI+RLW/TNi0C19/itK/yao0G57lcI02l6Wi1AOgZlW nnv91eYvvP8VmboaVzSEgmlm2j4lMAY8XhXbzN4GVGMhwpz+lL07wF94ng9MKtdhn4 cYloRIbcWwVDuU82l2PXSow9X8ai0ODCVMN7tBkX8vej7Q1wbOLZuyUubVaIRb1Z7X pYxG6aITgHmRg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] ASoC: imx-pcm-rpmsg: Destroy the workqueue after the component is gone Reply-To: sashiko-reviews@lists.linux.dev To: "Arina Kharlamova" Cc: linux-sound@vger.kernel.org, imx@lists.linux.dev, Frank.Li@kernel.org In-Reply-To: <20261129-s2p-d102-v1-1-3e8ad20db1b9@mbzuai.ac.ae> References: <20261129-s2p-d102-v1-1-3e8ad20db1b9@mbzuai.ac.ae> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 07:37:31 +0000 X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [Critical] ASoC: fsl_rpmsg: non-sync timer_delete() in imx_rpmsg_pcm_close() [1] -- commit d5d77f25c6ce2edfdba6c5018de29919ea8a86b3 Author: Arina Kharlamova ASoC: imx-pcm-rpmsg: Destroy the workqueue after the component is gone This commit switches the rpmsg workqueue allocation in imx_rpmsg_pcm_probe() to devm_alloc_ordered_workqueue() so that devres destroys the workqueue after unregistering the ASoC component, and removes the manual cleanup in imx_rpmsg_pcm_remove() and the probe error path. > diff --git a/sound/soc/fsl/imx-pcm-rpmsg.c b/sound/soc/fsl/imx-pcm-rpmsg.c > index 6852f49a18adc..266ce3b3d3335 100644 > --- a/sound/soc/fsl/imx-pcm-rpmsg.c > +++ b/sound/soc/fsl/imx-pcm-rpmsg.c > @@ -696,7 +696,7 @@ static void imx_rpmsg_pcm_work(struct work_struct *wo= rk) > static int imx_rpmsg_pcm_probe(struct platform_device *pdev) > { > struct rpmsg_info *info; > - int ret, i; > + int i; > =20 > info =3D devm_kzalloc_obj(&pdev->dev, *info); > if (!info) > @@ -707,10 +707,11 @@ static int imx_rpmsg_pcm_probe(struct platform_devi= ce *pdev) > info->rpdev =3D container_of(pdev->dev.parent, struct rpmsg_device, dev= ); > info->dev =3D &pdev->dev; > /* Setup work queue */ > - info->rpmsg_wq =3D alloc_ordered_workqueue(info->rpdev->id.name, > - WQ_HIGHPRI | > - WQ_UNBOUND | > - WQ_FREEZABLE); > + info->rpmsg_wq =3D devm_alloc_ordered_workqueue(&pdev->dev, > + info->rpdev->id.name, > + WQ_HIGHPRI | > + WQ_UNBOUND | > + WQ_FREEZABLE); [Severity: Critical] This problem wasn't introduced by this patch, but can imx_rpmsg_timer_callback() race with stream teardown in imx_rpmsg_pcm_close() [1] and queue work onto info->rpmsg_wq after the workqueue has been flushed? sound/soc/fsl/imx-pcm-rpmsg.c:imx_rpmsg_pcm_close() { ... info->send_message(msg, info); timer_delete(&info->stream_timer[substream->stream].timer); ... } Because timer_delete() does not wait for a concurrently running timer callback to finish, imx_rpmsg_timer_callback() on another CPU can enqueue new PERIOD_DONE work via imx_rpmsg_insert_workqueue() after flush_workqueue(info->rpmsg_wq) and after the TX_CLOSE or RX_CLOSE command has been sent: CPU0 CPU1 imx_rpmsg_pcm_hw_free() flush_workqueue(info->rpmsg_wq) imx_rpmsg_timer_callback() imx_rpmsg_insert_workqueue() imx_rpmsg_pcm_close() info->send_message(msg, info) timer_delete(...) If the queued work runs after the stream resources or workqueue are torn down, this causes a use-after-free. Using timer_delete_sync() before flushing the workqueue and sending the close message would prevent this race. [1] https://sashiko.dev/#/bug/linux-df8136ab-43bf-42a8-9969-f817dabe9dcb --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129-s2p-d102-v= 1-1-3e8ad20db1b9@mbzuai.ac.ae?part=3D1