Skip to content

Commit 63cecc8

Browse files
ujfalusiplbossart
authored andcommitted
ASoC: SOF: Intel: mtl: Do not process IPC reply before firmware boot
It is not yet clear, but it is possible to create a firmware so broken that it will send a reply message before a FW_READY message (it is not yet clear if FW_READY will arrive later). Since the reply_data is allocated only after the FW_READY message, this will lead to a NULL pointer dereference if not filtered out. Reported-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 255cc1a commit 63cecc8

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

sound/soc/sof/intel/mtl.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -513,17 +513,23 @@ static irqreturn_t mtl_ipc_irq_thread(int irq, void *context)
513513
*/
514514
if (primary & SOF_IPC4_MSG_DIR_MASK) {
515515
/* Reply received */
516-
struct sof_ipc4_msg *data = sdev->ipc->msg.reply_data;
516+
if (likely(sdev->fw_state == SOF_FW_BOOT_COMPLETE)) {
517+
struct sof_ipc4_msg *data = sdev->ipc->msg.reply_data;
517518

518-
data->primary = primary;
519-
data->extension = extension;
519+
data->primary = primary;
520+
data->extension = extension;
520521

521-
spin_lock_irq(&sdev->ipc_lock);
522+
spin_lock_irq(&sdev->ipc_lock);
522523

523-
snd_sof_ipc_get_reply(sdev);
524-
snd_sof_ipc_reply(sdev, data->primary);
524+
snd_sof_ipc_get_reply(sdev);
525+
snd_sof_ipc_reply(sdev, data->primary);
525526

526-
spin_unlock_irq(&sdev->ipc_lock);
527+
spin_unlock_irq(&sdev->ipc_lock);
528+
} else {
529+
dev_dbg_ratelimited(sdev->dev,
530+
"IPC reply before FW_READY: %#x|%#x\n",
531+
primary, extension);
532+
}
527533
} else {
528534
/* Notification received */
529535
notification_data.primary = primary;

0 commit comments

Comments
 (0)