Skip to content

Commit b37bb25

Browse files
committed
audio: host: Add NULL check for local buffer retrieval
Add NULL pointer check after calling `comp_dev_get_first_data_consumer` and `comp_dev_get_first_data_producer` functions in host_common_params. These functions can return NULL if no appropriate buffer is found in the component's connection list. Without this check, a NULL pointer would be assigned to hd->local_buffer and could cause crashes in subsequent operations that assume a valid buffer pointer. The error handling returns -EINVAL and logs an appropriate error message to help with debugging pipeline configuration issues. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
1 parent e23f9b1 commit b37bb25

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/audio/host-zephyr.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,11 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev,
903903
else
904904
hd->local_buffer = comp_dev_get_first_data_producer(dev);
905905

906+
if (!hd->local_buffer) {
907+
comp_err(dev, "no local buffer found");
908+
return -EINVAL;
909+
}
910+
906911
period_bytes = dev->frames * get_frame_bytes(params->frame_fmt, params->channels);
907912

908913
if (!period_bytes) {

0 commit comments

Comments
 (0)