Reversed locking order of sImageLoadMutex and sImageMutex in
unload_kernel_add_on(). The former one could lead to deadlocks with load_kernel_add_on() (e.g. occasionally the boot process would hang). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20485 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -54,8 +54,9 @@ typedef struct elf_linked_image {
|
|||||||
static hash_table *sImagesHash;
|
static hash_table *sImagesHash;
|
||||||
|
|
||||||
static struct elf_image_info *sKernelImage = NULL;
|
static struct elf_image_info *sKernelImage = NULL;
|
||||||
static mutex sImageMutex;
|
static mutex sImageMutex; // guards sImagesHash
|
||||||
static mutex sImageLoadMutex;
|
static mutex sImageLoadMutex; // serializes loading/unloading add-ons
|
||||||
|
// locking order sImageLoadMutex -> sImageMutex
|
||||||
static bool sInitialized = false;
|
static bool sInitialized = false;
|
||||||
|
|
||||||
|
|
||||||
@@ -1449,19 +1450,18 @@ unload_kernel_add_on(image_id id)
|
|||||||
struct elf_image_info *image;
|
struct elf_image_info *image;
|
||||||
status_t status;
|
status_t status;
|
||||||
|
|
||||||
|
mutex_lock(&sImageLoadMutex);
|
||||||
mutex_lock(&sImageMutex);
|
mutex_lock(&sImageMutex);
|
||||||
|
|
||||||
image = find_image(id);
|
image = find_image(id);
|
||||||
if (image != NULL) {
|
if (image != NULL)
|
||||||
mutex_lock(&sImageLoadMutex);
|
|
||||||
|
|
||||||
status = unload_elf_image(image);
|
status = unload_elf_image(image);
|
||||||
|
else
|
||||||
mutex_unlock(&sImageLoadMutex);
|
|
||||||
} else
|
|
||||||
status = B_BAD_IMAGE_ID;
|
status = B_BAD_IMAGE_ID;
|
||||||
|
|
||||||
mutex_unlock(&sImageMutex);
|
mutex_unlock(&sImageMutex);
|
||||||
|
mutex_unlock(&sImageLoadMutex);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user