From 25174582be0136e3a9028bf7ad99604244187d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 13 Oct 2008 13:38:01 +0000 Subject: [PATCH] Fixed two problems recently introduced by korli and found by aldeck: * When invalidating unused settings, we should remove the handle from the list before freeing it, or else the settings list will be corrupted. * We should protect the safemode settings against being removed, or else they won't be availabe anymore after we mounted the boot device. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28033 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/libroot/os/driver_settings.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/system/libroot/os/driver_settings.c b/src/system/libroot/os/driver_settings.c index 91e8eafd9a..61f265ad9f 100644 --- a/src/system/libroot/os/driver_settings.c +++ b/src/system/libroot/os/driver_settings.c @@ -646,9 +646,15 @@ driver_settings_init(kernel_args *args) strlcpy(handle->name, settings->name, sizeof(handle->name)); handle->magic = 0; - handle->ref_count = 0; - // this triggers parsing the settings when they are actually used + + if (!strcmp(handle->name, B_SAFEMODE_DRIVER_SETTINGS)) { + // These settings cannot be reloaded, so we better don't through + // them away. + handle->ref_count = 1; + } else + handle->ref_count = 0; + list_add_item(&sHandles, handle); settings = settings->next; @@ -700,7 +706,9 @@ load_driver_settings(const char *driverName) mutex_lock(&sLock); handle = find_driver_settings(driverName); if (handle != NULL && handle->ref_count == 0 && gBootDevice > 0) { - // an handle with a zero ref_count should be unloaded if /boot is available + // A handle with a zero ref_count should be unloaded if /boot is + // available. + list_remove_link(&handle->link); free_settings(handle); } else if (handle != NULL) { handle->ref_count++;