Skip to content

Commit b5ddf37

Browse files
author
Jyri Sarha
committed
modules: Apparently asking 0 alignment is dangerous, use 4 as default
The current rballoc_align() implementation has this line: assert(IS_ALIGNED(mem, align)); Which will cause division by zero due to IS_ALIGNED() Zephyr implementation: define IS_ALIGNED(ptr, align) (((uintptr_t)(ptr)) % (align) == 0) So better use 4 as the default value. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent cb65c6a commit b5ddf37

File tree

1 file changed

+4
-2
lines changed
  • src/include/sof/audio/module_adapter/module

1 file changed

+4
-2
lines changed

src/include/sof/audio/module_adapter/module/generic.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,15 @@ int module_init(struct processing_module *mod);
191191
void *mod_balloc_align(struct processing_module *mod, size_t size, size_t alignment);
192192
static inline void *mod_balloc(struct processing_module *mod, size_t size)
193193
{
194-
return mod_balloc_align(mod, size, 0);
194+
/* IS_ALIGNED() crashes if alignment is 0, so use pointer size as default alignment */
195+
return mod_balloc_align(mod, size, sizeof(void *));
195196
}
196197

197198
void *mod_alloc_align(struct processing_module *mod, size_t size, size_t alignment);
198199
static inline void *mod_alloc(struct processing_module *mod, size_t size)
199200
{
200-
return mod_alloc_align(mod, size, 0);
201+
/* IS_ALIGNED() crashes if alignment is 0, so use pointer size as default alignment */
202+
return mod_alloc_align(mod, size, sizeof(void *));
201203
}
202204

203205
static inline void *mod_zalloc(struct processing_module *mod, size_t size)

0 commit comments

Comments
 (0)