Skip to content

Commit f514248

Browse files
haruki3hhhbroonie
authored andcommitted
ASoC: fsl_xcvr: fix missing lock in fsl_xcvr_mode_put()
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 85352e5 commit f514248

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

sound/soc/fsl/fsl_xcvr.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,13 @@ static int fsl_xcvr_mode_put(struct snd_kcontrol *kcontrol,
223223

224224
xcvr->mode = snd_soc_enum_item_to_val(e, item[0]);
225225

226+
down_read(&card->snd_card->controls_rwsem);
226227
fsl_xcvr_activate_ctl(dai, fsl_xcvr_arc_mode_kctl.name,
227228
(xcvr->mode == FSL_XCVR_MODE_ARC));
228229
fsl_xcvr_activate_ctl(dai, fsl_xcvr_earc_capds_kctl.name,
229230
(xcvr->mode == FSL_XCVR_MODE_EARC));
231+
up_read(&card->snd_card->controls_rwsem);
232+
230233
/* Allow playback for SPDIF only */
231234
rtd = snd_soc_get_pcm_runtime(card, card->dai_link);
232235
rtd->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream_count =

0 commit comments

Comments
 (0)