Skip to content

Commit 441173f

Browse files
committed
audio: check NULL linked buffer in .trigger()
If .trigger() is wrongly called on a pipeline, that isn't connected to a DAI, its edge component will hit a NULL buffer, which then has to be checked. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 4da9683 commit 441173f

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/audio/asrc/asrc.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,14 @@ static int asrc_dai_find(struct comp_dev *dev, struct comp_data *cd)
452452
/* In push mode check if sink component is DAI */
453453
do {
454454
sinkb = comp_dev_get_first_data_consumer(dev);
455+
if (!sinkb) {
456+
comp_err(asrc_dev, "At end: NULL buffer, no DAI found.");
457+
return -EINVAL;
458+
}
455459

456460
dev = comp_buffer_get_sink_component(sinkb);
457-
458461
if (!dev) {
459-
comp_err(asrc_dev, "At end, no DAI found.");
462+
comp_err(asrc_dev, "At end: NULL device, no DAI found.");
460463
return -EINVAL;
461464
}
462465

@@ -470,11 +473,14 @@ static int asrc_dai_find(struct comp_dev *dev, struct comp_data *cd)
470473
/* In pull mode check if source component is DAI */
471474
do {
472475
sourceb = comp_dev_get_first_data_producer(dev);
476+
if (!sourceb) {
477+
comp_err(asrc_dev, "At beginning: NULL buffer, no DAI found.");
478+
return -EINVAL;
479+
}
473480

474481
dev = comp_buffer_get_source_component(sourceb);
475-
476482
if (!dev) {
477-
comp_err(asrc_dev, "At beginning, no DAI found.");
483+
comp_err(asrc_dev, "At beginning: NULL device, no DAI found.");
478484
return -EINVAL;
479485
}
480486

src/audio/selector/selector.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,14 @@ static int selector_trigger(struct comp_dev *dev, int cmd)
344344
comp_dbg(dev, "selector_trigger()");
345345

346346
sourceb = comp_dev_get_first_data_producer(dev);
347+
if (!sourceb) {
348+
comp_err(dev, "source disconnected");
349+
return -ENODEV;
350+
}
347351

348352
ret = comp_set_state(dev, cmd);
353+
if (ret == COMP_STATUS_STATE_ALREADY_SET)
354+
ret = 0;
349355

350356
/* TODO: remove in the future after adding support for case when
351357
* kpb_init_draining() and kpb_draining_task() are interrupted by

0 commit comments

Comments
 (0)