From 20550681049d22f03ec5ed1aa715faff165e9058 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Fri, 25 Feb 2022 20:28:22 +0200 Subject: [PATCH] audio_buffer: Allow NULL to be passed to buffer_free This will allow users to pass NULL to buffer_free. This fixes codec_adapter_free crash, where mod->local_buff is only allocated when the module is prepared. With dynamic pipelines we could have the situation where the pipeline is created then SOF device enters suspend and pipeline is destroyed. Thus we try to free unallocated mod->local_buf. Fix this by allowing buffer_free to live free when receiving a NULL pointer. Signed-off-by: Daniel Baluta --- src/audio/buffer.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/audio/buffer.c b/src/audio/buffer.c index 64cf2eafe..b2c1e00ed 100644 --- a/src/audio/buffer.c +++ b/src/audio/buffer.c @@ -161,6 +161,9 @@ void buffer_free(struct comp_buffer *buffer) buf_dbg(buffer, "buffer_free()"); + if (!buffer) + return; + notifier_event(buffer, NOTIFIER_ID_BUFFER_FREE, NOTIFIER_TARGET_CORE_LOCAL, &cb_data, sizeof(cb_data));