Fix a bug that was tripping an assert in the kernel module code.
When iterating through modules, the iterator was loading the module file, inserting it into the module image hash. Then, the first time get_module() was called on a module contained in the image, it was trying to load the image again. It probably actually was. Changed the logic to call get_module_image() which checks to see if it's already loaded. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21476 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
2d6d529814
commit
554fdaa33a
@ -359,16 +359,22 @@ get_module_image(const char *path, module_image **_image)
|
|||||||
|
|
||||||
TRACE(("get_module_image(path = \"%s\", _image = %p)\n", path, _image));
|
TRACE(("get_module_image(path = \"%s\", _image = %p)\n", path, _image));
|
||||||
|
|
||||||
|
recursive_lock_lock(&sModulesLock);
|
||||||
|
|
||||||
image = (module_image *)hash_lookup(sModuleImagesHash, path);
|
image = (module_image *)hash_lookup(sModuleImagesHash, path);
|
||||||
if (image == NULL) {
|
if (image == NULL) {
|
||||||
status_t status = load_module_image(path, &image);
|
status_t status = load_module_image(path, &image);
|
||||||
if (status < B_OK)
|
if (status < B_OK) {
|
||||||
|
recursive_lock_unlock(&sModulesLock);
|
||||||
return status;
|
return status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_add(&image->ref_count, 1);
|
atomic_add(&image->ref_count, 1);
|
||||||
*_image = image;
|
*_image = image;
|
||||||
|
|
||||||
|
recursive_lock_unlock(&sModulesLock);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,9 +452,8 @@ check_module_image(const char *path, const char *searchedName)
|
|||||||
int index = 0, match = B_ENTRY_NOT_FOUND;
|
int index = 0, match = B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
TRACE(("check_module_image(path = \"%s\", searchedName = \"%s\")\n", path, searchedName));
|
TRACE(("check_module_image(path = \"%s\", searchedName = \"%s\")\n", path, searchedName));
|
||||||
ASSERT(hash_lookup(sModuleImagesHash, path) == NULL);
|
|
||||||
|
|
||||||
if (load_module_image(path, &image) < B_OK)
|
if (get_module_image(path, &image) < B_OK)
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
for (info = image->info; *info; info++) {
|
for (info = image->info; *info; info++) {
|
||||||
@ -467,6 +472,9 @@ check_module_image(const char *path, const char *searchedName)
|
|||||||
unload_module_image(image, path);
|
unload_module_image(image, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// decrement the ref we got in get_module_image
|
||||||
|
put_module_image(image);
|
||||||
|
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user