Commit a5c75940 authored by Takashi Iwai's avatar Takashi Iwai Committed by Khalid Elmously

ALSA: ice1724: Fix sleep-in-atomic in Infrasonic Quartet support code

BugLink: https://bugs.launchpad.net/bugs/1859640

commit 0aec96f5 upstream.

Jia-Ju Bai reported a possible sleep-in-atomic scenario in the ice1724
driver with Infrasonic Quartet support code: namely, ice->set_rate
callback gets called inside ice->reg_lock spinlock, while the callback
in quartet.c holds ice->gpio_mutex.

This patch fixes the invalid call: it simply moves the calls of
ice->set_rate and ice->set_mclk callbacks outside the spinlock.
Reported-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/5d43135e-73b9-a46a-2155-9e91d0dcdf83@gmail.com
Link: https://lore.kernel.org/r/20191218192606.12866-1-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent f02e8972
...@@ -663,6 +663,7 @@ static int snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate, ...@@ -663,6 +663,7 @@ static int snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
unsigned long flags; unsigned long flags;
unsigned char mclk_change; unsigned char mclk_change;
unsigned int i, old_rate; unsigned int i, old_rate;
bool call_set_rate = false;
if (rate > ice->hw_rates->list[ice->hw_rates->count - 1]) if (rate > ice->hw_rates->list[ice->hw_rates->count - 1])
return -EINVAL; return -EINVAL;
...@@ -686,7 +687,7 @@ static int snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate, ...@@ -686,7 +687,7 @@ static int snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
* setting clock rate for internal clock mode */ * setting clock rate for internal clock mode */
old_rate = ice->get_rate(ice); old_rate = ice->get_rate(ice);
if (force || (old_rate != rate)) if (force || (old_rate != rate))
ice->set_rate(ice, rate); call_set_rate = true;
else if (rate == ice->cur_rate) { else if (rate == ice->cur_rate) {
spin_unlock_irqrestore(&ice->reg_lock, flags); spin_unlock_irqrestore(&ice->reg_lock, flags);
return 0; return 0;
...@@ -694,12 +695,14 @@ static int snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate, ...@@ -694,12 +695,14 @@ static int snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
} }
ice->cur_rate = rate; ice->cur_rate = rate;
spin_unlock_irqrestore(&ice->reg_lock, flags);
if (call_set_rate)
ice->set_rate(ice, rate);
/* setting master clock */ /* setting master clock */
mclk_change = ice->set_mclk(ice, rate); mclk_change = ice->set_mclk(ice, rate);
spin_unlock_irqrestore(&ice->reg_lock, flags);
if (mclk_change && ice->gpio.i2s_mclk_changed) if (mclk_change && ice->gpio.i2s_mclk_changed)
ice->gpio.i2s_mclk_changed(ice); ice->gpio.i2s_mclk_changed(ice);
if (ice->gpio.set_pro_rate) if (ice->gpio.set_pro_rate)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment