From 491b29f7bbbd66e852857c169769ddfe668e72f6 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 2 Nov 2023 16:55:59 +0200 Subject: [PATCH] Audio: RTNR stub: Avoid error in rtnr_init() with null pointer The init code checks for NULL and errors, so need to return from RTKMA_API_Context_Create() a valid allocated address. The free is added to RTKMA_API_Context_Free(). Signed-off-by: Seppo Ingalsuo --- src/audio/rtnr/rtnr_stub.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/audio/rtnr/rtnr_stub.c b/src/audio/rtnr/rtnr_stub.c index bdacb4790..507191c67 100644 --- a/src/audio/rtnr/rtnr_stub.c +++ b/src/audio/rtnr/rtnr_stub.c @@ -6,6 +6,7 @@ // #include +#include void RTKMA_API_S16_Default(void *Context, struct audio_stream_rtnr **sources, struct audio_stream_rtnr *sink, int frames, @@ -36,11 +37,16 @@ void RTKMA_API_Prepare(void *Context) void *RTKMA_API_Context_Create(int sample_rate) { - return NULL; + /* Allocate something, to avoid return NULL and cause error + * in check of success of this. + */ + return rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, 42); } void RTKMA_API_Context_Free(void *Context) -{} +{ + rfree(Context); +} int RTKMA_API_Parameter_Size(void *Context, unsigned int IDs) {