Skip to content

Commit cd6b991

Browse files
cristiccgregkh
authored andcommitted
ASoC: nau8821: Cancel delayed work on component remove
[ Upstream commit dbd3fd0 ] Attempting to unload the driver while a jack detection work is pending would likely crash the kernel when it is eventually scheduled for execution: [ 1984.896308] BUG: unable to handle page fault for address: ffffffffc10c2a20 [...] [ 1984.896388] Hardware name: Valve Jupiter/Jupiter, BIOS F7A0131 01/30/2024 [ 1984.896396] Workqueue: events nau8821_jdet_work [snd_soc_nau8821] [ 1984.896414] RIP: 0010:__mutex_lock+0x9f/0x11d0 [...] [ 1984.896504] Call Trace: [ 1984.896511] <TASK> [ 1984.896524] ? snd_soc_dapm_disable_pin+0x26/0x60 [snd_soc_core] [ 1984.896572] ? snd_soc_dapm_disable_pin+0x26/0x60 [snd_soc_core] [ 1984.896596] snd_soc_dapm_disable_pin+0x26/0x60 [snd_soc_core] [ 1984.896622] nau8821_jdet_work+0xeb/0x1e0 [snd_soc_nau8821] [ 1984.896636] process_one_work+0x211/0x590 [ 1984.896649] ? srso_return_thunk+0x5/0x5f [ 1984.896670] worker_thread+0x1cd/0x3a0 Cancel unscheduled jdet_work or wait for its execution to finish before the component driver gets removed. Fixes: aab1ad1 ("ASoC: nau8821: new driver") Fixes: ee70bac ("ASoC: nau8821: Avoid unnecessary blocking in IRQ handler") Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Link: https://patch.msgid.link/20251231-nau8821-cleanup-v1-2-6b0b76cbbb64@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 3f119c3 commit cd6b991

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

sound/soc/codecs/nau8821.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,14 @@ static int nau8821_component_probe(struct snd_soc_component *component)
11471147
return 0;
11481148
}
11491149

1150+
static void nau8821_component_remove(struct snd_soc_component *component)
1151+
{
1152+
struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component);
1153+
1154+
if (nau8821->jdet_active)
1155+
cancel_delayed_work_sync(&nau8821->jdet_work);
1156+
};
1157+
11501158
/**
11511159
* nau8821_calc_fll_param - Calculate FLL parameters.
11521160
* @fll_in: external clock provided to codec.
@@ -1505,6 +1513,7 @@ static int __maybe_unused nau8821_resume(struct snd_soc_component *component)
15051513

15061514
static const struct snd_soc_component_driver nau8821_component_driver = {
15071515
.probe = nau8821_component_probe,
1516+
.remove = nau8821_component_remove,
15081517
.set_sysclk = nau8821_set_sysclk,
15091518
.set_pll = nau8821_set_fll,
15101519
.set_bias_level = nau8821_set_bias_level,

0 commit comments

Comments
 (0)