Skip to content

Commit d4cd762

Browse files
softwareckilgirdwood
authored andcommitted
lib_manager: Add module id verification
Add verification of the module id passed as a parameter to the lib_manager_get_mod_ctx function. Add error handling to the lib_manager_free_module function. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
1 parent 6ac84d4 commit d4cd762

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/include/sof/lib_manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static inline struct lib_manager_mod_ctx *lib_manager_get_mod_ctx(int module_id)
145145
uint32_t lib_id = LIB_MANAGER_GET_LIB_ID(module_id);
146146
struct ext_library *_ext_lib = ext_lib_get();
147147

148-
if (!_ext_lib)
148+
if (!_ext_lib || lib_id >= LIB_MANAGER_MAX_LIBS)
149149
return NULL;
150150

151151
return _ext_lib->desc[lib_id];

src/library_manager/lib_manager.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@ int lib_manager_free_module(const uint32_t component_id)
386386
tr_dbg(&lib_manager_tr, "mod_id: %#x", component_id);
387387

388388
mod = lib_manager_get_module_manifest(module_id);
389+
if (!mod) {
390+
tr_err(&lib_manager_tr, "failed to get module descriptor");
391+
return -EINVAL;
392+
}
389393

390394
if (module_is_llext(mod))
391395
return llext_manager_free_module(component_id);

0 commit comments

Comments
 (0)