Skip to content

Commit 06f3a0a

Browse files
Stefan Bindingtiwai
authored andcommitted
ALSA: hda: hda_cs_dsp_ctl: Ensure pwr_lock is held before reading/writing controls
These apis require the pwr_lock to be held. Signed-off-by: Stefan Binding <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 49b0dea commit 06f3a0a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

sound/pci/hda/hda_cs_dsp_ctl.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,14 @@ EXPORT_SYMBOL_NS_GPL(hda_cs_dsp_control_remove, SND_HDA_CS_DSP_CONTROLS);
199199
int hda_cs_dsp_write_ctl(struct cs_dsp *dsp, const char *name, int type,
200200
unsigned int alg, const void *buf, size_t len)
201201
{
202-
struct cs_dsp_coeff_ctl *cs_ctl = cs_dsp_get_ctl(dsp, name, type, alg);
202+
struct cs_dsp_coeff_ctl *cs_ctl;
203203
struct hda_cs_dsp_coeff_ctl *ctl;
204204
int ret;
205205

206+
mutex_lock(&dsp->pwr_lock);
207+
cs_ctl = cs_dsp_get_ctl(dsp, name, type, alg);
206208
ret = cs_dsp_coeff_write_ctrl(cs_ctl, 0, buf, len);
209+
mutex_unlock(&dsp->pwr_lock);
207210
if (ret)
208211
return ret;
209212

@@ -221,7 +224,13 @@ EXPORT_SYMBOL_NS_GPL(hda_cs_dsp_write_ctl, SND_HDA_CS_DSP_CONTROLS);
221224
int hda_cs_dsp_read_ctl(struct cs_dsp *dsp, const char *name, int type,
222225
unsigned int alg, void *buf, size_t len)
223226
{
224-
return cs_dsp_coeff_read_ctrl(cs_dsp_get_ctl(dsp, name, type, alg), 0, buf, len);
227+
int ret;
228+
229+
mutex_lock(&dsp->pwr_lock);
230+
ret = cs_dsp_coeff_read_ctrl(cs_dsp_get_ctl(dsp, name, type, alg), 0, buf, len);
231+
mutex_unlock(&dsp->pwr_lock);
232+
233+
return ret;
225234

226235
}
227236
EXPORT_SYMBOL_NS_GPL(hda_cs_dsp_read_ctl, SND_HDA_CS_DSP_CONTROLS);

0 commit comments

Comments
 (0)