Skip to content

Commit adb2c75

Browse files
committed
audio: module-adapter: simplify a check
Checking for size == 0 can be done in the beginning of z_impl_mod_alloc_ext() to simplify clean up. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent d2e4970 commit adb2c75

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

‎src/audio/module_adapter/module/generic.c‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ void *z_impl_mod_alloc_ext(struct processing_module *mod, uint32_t flags, size_t
247247
struct module_resources *res = &mod->priv.resources;
248248
struct module_resource *container;
249249

250+
if (!size) {
251+
comp_err(mod->dev, "requested allocation of 0 bytes.");
252+
return NULL;
253+
}
254+
250255
k_mutex_lock(&mod_res_lock, K_FOREVER);
251256

252257
container = container_get(mod);
@@ -255,13 +260,6 @@ void *z_impl_mod_alloc_ext(struct processing_module *mod, uint32_t flags, size_t
255260
return NULL;
256261
}
257262

258-
if (!size) {
259-
comp_err(mod->dev, "requested allocation of 0 bytes.");
260-
container_put(mod, container);
261-
k_mutex_unlock(&mod_res_lock);
262-
return NULL;
263-
}
264-
265263
/* Allocate memory for module */
266264
void *ptr = sof_ctx_alloc(res->alloc, flags, size, alignment);
267265

0 commit comments

Comments
 (0)