public inbox for linuxppc-dev@ozlabs.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: fsl_xcvr: fix missing lock in fsl_xcvr_mode_put()
@ 2026-02-02 17:41 Ziyi Guo
  2026-02-04 13:03 ` Mark Brown
  2026-02-10  7:18 ` Alexander Stein
  0 siblings, 2 replies; 5+ messages in thread
From: Ziyi Guo @ 2026-02-02 17:41 UTC (permalink / raw)
  To: Shengjiu Wang, Xiubo Li
  Cc: Fabio Estevam, Nicolin Chen, Mark Brown, Liam Girdwood,
	Jaroslav Kysela, Takashi Iwai, linux-sound, linuxppc-dev,
	linux-kernel, Ziyi Guo

fsl_xcvr_activate_ctl() has 
lockdep_assert_held(&card->snd_card->controls_rwsem),
but fsl_xcvr_mode_put() calls it without acquiring this lock.

Other callers of fsl_xcvr_activate_ctl() in fsl_xcvr_startup() and
fsl_xcvr_shutdown() properly acquire the lock with down_read()/up_read().

Add the missing down_read()/up_read() calls around fsl_xcvr_activate_ctl()
in fsl_xcvr_mode_put() to fix the lockdep assertion and prevent potential
race conditions when multiple userspace threads access the control.

Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
---
 sound/soc/fsl/fsl_xcvr.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/soc/fsl/fsl_xcvr.c b/sound/soc/fsl/fsl_xcvr.c
index a268fb81a2f8..0b9dd64b9a82 100644
--- a/sound/soc/fsl/fsl_xcvr.c
+++ b/sound/soc/fsl/fsl_xcvr.c
@@ -223,10 +223,13 @@ static int fsl_xcvr_mode_put(struct snd_kcontrol *kcontrol,
 
 	xcvr->mode = snd_soc_enum_item_to_val(e, item[0]);
 
+	down_read(&card->snd_card->controls_rwsem);
 	fsl_xcvr_activate_ctl(dai, fsl_xcvr_arc_mode_kctl.name,
 			      (xcvr->mode == FSL_XCVR_MODE_ARC));
 	fsl_xcvr_activate_ctl(dai, fsl_xcvr_earc_capds_kctl.name,
 			      (xcvr->mode == FSL_XCVR_MODE_EARC));
+	up_read(&card->snd_card->controls_rwsem);
+
 	/* Allow playback for SPDIF only */
 	rtd = snd_soc_get_pcm_runtime(card, card->dai_link);
 	rtd->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream_count =
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-02-10 13:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-02 17:41 [PATCH] ASoC: fsl_xcvr: fix missing lock in fsl_xcvr_mode_put() Ziyi Guo
2026-02-04 13:03 ` Mark Brown
2026-02-10  7:18 ` Alexander Stein
2026-02-10 13:55   ` Ziyi Guo
2026-02-10 13:57     ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox