[PATCH for v6.3-rc] ASoC: SOF: avoid a NULL dereference with unsupported widgets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Guennadi Liakhovetski <guennadi.liakhovetski@xxxxxxxxxxxxxxx>

If an IPC4 topology contains an unsupported widget, its .module_info
field won't be set, then sof_ipc4_route_setup() will cause a kernel
Oops trying to dereference it. Add a check for such cases.

Cc: stable@xxxxxxxxxxxxxxx # 6.2
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@xxxxxxxxxxxxxxx>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@xxxxxxxxxxxxxxx>
---
Hi Mark,

This patch is generated on top of 6.3-rc4, it will have conflict with asoc-next
because we have ChainDMA scheduled for 6.4 in there.
I should have taken this patch a faster track, but missed it when arranging the
patches, features.
We noticed this when trying to use our development IPC4 topologies with mainline
which does not yet able to handle the process module types (slated fro 6.4).
IPC4 is still evolving so it is not rare that fw/tplg/kernel needs to be
lock-stepped, but NULL pointer dereference should not happen.

This is how the merge conflict resolution should end up between 6.3 and 6.4:

int ret;

/* no route set up if chain DMA is used */
if (src_pipeline->use_chain_dma || sink_pipeline->use_chain_dma) {
	if (!src_pipeline->use_chain_dma || !sink_pipeline->use_chain_dma) {
		dev_err(sdev->dev,
			"use_chain_dma must be set for both src %s and sink %s pipelines\n",
			src_widget->widget->name, sink_widget->widget->name);
		return -EINVAL;
	}
	return 0;
}

if (!src_fw_module || !sink_fw_module) {
	/* The NULL module will print as "(efault)" */
	dev_err(sdev->dev, "source %s or sink %s widget weren't set up properly\n",
		src_fw_module->man4_module_entry.name,
		sink_fw_module->man4_module_entry.name);
	return -ENODEV;
}

sroute->src_queue_id = sof_ipc4_get_queue_id(src_widget, sink_widget,
					     SOF_PIN_TYPE_SOURCE);


Can you send this patch for 6.3 cycle?

Thank you,
Peter

 sound/soc/sof/ipc4-topology.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c
index a623707c8ffc..669b99a4f76e 100644
--- a/sound/soc/sof/ipc4-topology.c
+++ b/sound/soc/sof/ipc4-topology.c
@@ -1805,6 +1805,14 @@ static int sof_ipc4_route_setup(struct snd_sof_dev *sdev, struct snd_sof_route *
 	u32 header, extension;
 	int ret;
 
+	if (!src_fw_module || !sink_fw_module) {
+		/* The NULL module will print as "(efault)" */
+		dev_err(sdev->dev, "source %s or sink %s widget weren't set up properly\n",
+			src_fw_module->man4_module_entry.name,
+			sink_fw_module->man4_module_entry.name);
+		return -ENODEV;
+	}
+
 	sroute->src_queue_id = sof_ipc4_get_queue_id(src_widget, sink_widget,
 						     SOF_PIN_TYPE_SOURCE);
 	if (sroute->src_queue_id < 0) {
-- 
2.40.0




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux