diff --git a/src/kernel/core/module.c b/src/kernel/core/module.c index 320bd28b9b..3324cfaf04 100644 --- a/src/kernel/core/module.c +++ b/src/kernel/core/module.c @@ -1376,7 +1376,8 @@ get_module(const char *path, module_info **_info) if (status == B_OK) { inc_module_ref_count(module); *_info = module->info; - } + } else if ((module->flags & B_BUILT_IN_MODULE) == 0) + put_module_image(module->module_image); recursive_lock_unlock(&sModulesLock); return status; @@ -1408,11 +1409,11 @@ put_module(const char *path) if (module->ref_count == 0) uninit_module(module); - - if ((module->flags & B_BUILT_IN_MODULE) == 0) - put_module_image(module->module_image); } + if ((module->flags & B_BUILT_IN_MODULE) == 0) + put_module_image(module->module_image); + recursive_lock_unlock(&sModulesLock); return B_OK; }