From 0812ea364fc5e2df7750d6929f09df534d7dc408 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Tue, 20 Dec 2022 08:02:48 +0100 Subject: [PATCH 1/4] copier: fix a potentially uninitialised warning The create_dai() function can return an uninitialised value. Fix it by reducing the scope of the variable. Signed-off-by: Guennadi Liakhovetski --- src/audio/copier/copier.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/audio/copier/copier.c b/src/audio/copier/copier.c index 1ecc6b23d933..827583e78349 100644 --- a/src/audio/copier/copier.c +++ b/src/audio/copier/copier.c @@ -312,7 +312,6 @@ static int create_dai(struct comp_dev *parent_dev, struct copier_data *cd, const struct comp_driver *drv; struct ipc_config_dai dai; int dai_count; - int ret; int i; drv = ipc4_get_drv((uint8_t *)&id); @@ -388,15 +387,17 @@ static int create_dai(struct comp_dev *parent_dev, struct copier_data *cd, } for (i = 0; i < dai_count; i++) { + int ret; + dai.dai_index = dai_index[i]; ret = init_dai(parent_dev, drv, config, copier, pipeline, &dai, type, i); if (ret) { comp_err(parent_dev, "failed to create dai"); - break; + return ret; } } - return ret; + return 0; } static int init_pipeline_reg(struct comp_dev *dev) From a7e2235508b983f0db8ccaf922384a447b0595ff Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Tue, 20 Dec 2022 08:06:51 +0100 Subject: [PATCH 2/4] data-blob: fix a NULL dereference If the main context variable is NULL, it cannot be used to print an error message. Since this actually should never happen, use an assertion similar to other similar cases in the file. Signed-off-by: Guennadi Liakhovetski --- src/audio/data_blob.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/audio/data_blob.c b/src/audio/data_blob.c index 359dbe0bba5f..8179225350db 100644 --- a/src/audio/data_blob.c +++ b/src/audio/data_blob.c @@ -281,11 +281,7 @@ int ipc4_comp_data_blob_set(struct comp_data_blob_handler *blob_handler, int ret; int valid_data_size; - if (!blob_handler) { - comp_err(blob_handler->dev, - "ipc4_comp_data_blob_set(): blob_handler is NULL!"); - return -EINVAL; - } + assert(blob_handler); comp_dbg(blob_handler->dev, "ipc4_comp_data_blob_set(): data_offset = %d", From 75bb458b6befaa8047b1dc12d35a2ed1a8156f5d Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Tue, 20 Dec 2022 08:10:35 +0100 Subject: [PATCH 3/4] ipc: ipc4: fix an uninitialised variable This is a theoretical case of an invalid pipeline status, handle it correctly. Signed-off-by: Guennadi Liakhovetski --- src/ipc/ipc4/handler.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ipc/ipc4/handler.c b/src/ipc/ipc4/handler.c index cd4fd74fd20b..c52b7671f3c9 100644 --- a/src/ipc/ipc4/handler.c +++ b/src/ipc/ipc4/handler.c @@ -275,6 +275,10 @@ static int set_pipeline_state(struct ipc_comp_dev *ppl_icd, uint32_t cmd, } if (ret == PPL_STATUS_SCHEDULED) *delayed = true; + break; + default: + tr_err(&ipc_tr, "ipc: invalid status %d for RESET", status); + return IPC4_INVALID_REQUEST; } /* From 0e40ee9007ffc01b541d8d249003a4f3eeb18507 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Tue, 20 Dec 2022 08:13:36 +0100 Subject: [PATCH 4/4] probe: simplify ipc4_get_buffer() Use a local variable in ipc4_get_buffer() to simplify it and remove redundant code. Signed-off-by: Guennadi Liakhovetski --- src/probe/probe.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/probe/probe.c b/src/probe/probe.c index 9f09e4374e37..5289936ab230 100644 --- a/src/probe/probe.c +++ b/src/probe/probe.c @@ -979,41 +979,33 @@ static struct comp_buffer *ipc4_get_buffer(struct ipc_comp_dev *dev, probe_point struct comp_buffer *buf; struct comp_buffer __sparse_cache *buf_c; struct list_item *sink_list, *source_list; + unsigned int queue_id; switch (probe_point.fields.type) { case PROBE_TYPE_INPUT: - if (list_is_empty(&dev->cd->bsource_list)) - return NULL; - list_for_item(source_list, &dev->cd->bsource_list) { buf = container_of(source_list, struct comp_buffer, sink_list); buf_c = buffer_acquire(buf); - - if (IPC4_SRC_QUEUE_ID(buf_c->id) == probe_point.fields.index) - break; - + queue_id = IPC4_SRC_QUEUE_ID(buf_c->id); buffer_release(buf_c); + + if (queue_id == probe_point.fields.index) + return buf; } break; case PROBE_TYPE_OUTPUT: - if (list_is_empty(&dev->cd->bsink_list)) - return NULL; - list_for_item(sink_list, &dev->cd->bsink_list) { buf = container_of(sink_list, struct comp_buffer, source_list); buf_c = buffer_acquire(buf); - - if (IPC4_SINK_QUEUE_ID(buf_c->id) == probe_point.fields.index) - break; - + queue_id = IPC4_SINK_QUEUE_ID(buf_c->id); buffer_release(buf_c); + + if (queue_id == probe_point.fields.index) + return buf; } - break; - default: - return NULL; } - buffer_release(buf_c); - return buf; + + return NULL; } #endif