Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/library_manager/llext_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,16 @@ static int llext_manager_mod_init(struct lib_manager_mod_ctx *ctx,
n_mod++;
}

/*
* A manifest with no distinct module segments would leave n_mod == 0,
* making the ctx->mod[n_mod - 1] accesses below index out of bounds
*/
if (!n_mod) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the change is good given some malloc() implementations do return a pointer, but I think the comment + commitmsg are misleading as SOF allocated do return NULL so if n_mod is zero, this function will return -ENOMEM on line 568. I think explicit check is still better, but please correct the commit and maybe reduce the inline comments. This is self-explanatory.

tr_err(&lib_manager_tr, "no module segments in %u entries",
desc->header.num_module_entries);
return -EINVAL;
}

/*
* Loadable modules are loaded to DRAM once and never unloaded from it.
* Context, related to them, is never freed
Expand Down
Loading