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 <daniel.baluta@nxp.com>
This commit is contained in:
Daniel Baluta 2022-02-25 20:28:22 +02:00 committed by Liam Girdwood
parent 6f71808e3e
commit 2055068104
1 changed files with 3 additions and 0 deletions

View File

@ -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));