Skip to content

Commit eceb543

Browse files
ranj063broonie
authored andcommitted
ASoC: SOF: core: fix null-ptr-deref bug during device removal
The DSP should be notified for device removal only if the probe was successful. Fixes the following KASAN bug: BUG: KASAN: null-ptr-deref in sof_ipc_tx_message+0x80/0x160 [snd_sof] Signed-off-by: Ranjani Sridharan <[email protected]> Signed-off-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Kai Vehmanen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 503ed52 commit eceb543

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

sound/soc/sof/core.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,15 +345,15 @@ int snd_sof_device_remove(struct device *dev)
345345
struct snd_sof_pdata *pdata = sdev->pdata;
346346
int ret;
347347

348-
ret = snd_sof_dsp_power_down_notify(sdev);
349-
if (ret < 0)
350-
dev_warn(dev, "error: %d failed to prepare DSP for device removal",
351-
ret);
352-
353348
if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE))
354349
cancel_work_sync(&sdev->probe_work);
355350

356351
if (sdev->fw_state > SOF_FW_BOOT_NOT_STARTED) {
352+
ret = snd_sof_dsp_power_down_notify(sdev);
353+
if (ret < 0)
354+
dev_warn(dev, "error: %d failed to prepare DSP for device removal",
355+
ret);
356+
357357
snd_sof_fw_unload(sdev);
358358
snd_sof_ipc_free(sdev);
359359
snd_sof_free_debug(sdev);

0 commit comments

Comments
 (0)