Commit c0eeedbb authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz Committed by Linus Torvalds

[PATCH] do not take ide_setting_sem under ide_lock

 From -mm tree, fixes oops when removing ide drivers.
parent 69320950
...@@ -1134,13 +1134,12 @@ ide_settings_t *ide_find_setting_by_name (ide_drive_t *drive, char *name) ...@@ -1134,13 +1134,12 @@ ide_settings_t *ide_find_setting_by_name (ide_drive_t *drive, char *name)
* *
* Automatically remove all the driver specific settings for this * Automatically remove all the driver specific settings for this
* drive. This function may sleep and must not be called from IRQ * drive. This function may sleep and must not be called from IRQ
* context. Takes the settings_lock * context. The caller must hold ide_setting_sem.
*/ */
static void auto_remove_settings (ide_drive_t *drive) static void auto_remove_settings (ide_drive_t *drive)
{ {
ide_settings_t *setting; ide_settings_t *setting;
down(&ide_setting_sem);
repeat: repeat:
setting = drive->settings; setting = drive->settings;
while (setting) { while (setting) {
...@@ -1150,7 +1149,6 @@ static void auto_remove_settings (ide_drive_t *drive) ...@@ -1150,7 +1149,6 @@ static void auto_remove_settings (ide_drive_t *drive)
} }
setting = setting->next; setting = setting->next;
} }
up(&ide_setting_sem);
} }
/** /**
...@@ -2408,9 +2406,11 @@ int ide_unregister_subdriver (ide_drive_t *drive) ...@@ -2408,9 +2406,11 @@ int ide_unregister_subdriver (ide_drive_t *drive)
{ {
unsigned long flags; unsigned long flags;
down(&ide_setting_sem);
spin_lock_irqsave(&ide_lock, flags); spin_lock_irqsave(&ide_lock, flags);
if (drive->usage || drive->driver == &idedefault_driver || DRIVER(drive)->busy) { if (drive->usage || drive->driver == &idedefault_driver || DRIVER(drive)->busy) {
spin_unlock_irqrestore(&ide_lock, flags); spin_unlock_irqrestore(&ide_lock, flags);
up(&ide_setting_sem);
return 1; return 1;
} }
#if defined(CONFIG_BLK_DEV_IDEPNP) && defined(CONFIG_PNP) && defined(MODULE) #if defined(CONFIG_BLK_DEV_IDEPNP) && defined(CONFIG_PNP) && defined(MODULE)
...@@ -2424,6 +2424,7 @@ int ide_unregister_subdriver (ide_drive_t *drive) ...@@ -2424,6 +2424,7 @@ int ide_unregister_subdriver (ide_drive_t *drive)
drive->driver = &idedefault_driver; drive->driver = &idedefault_driver;
setup_driver_defaults(drive); setup_driver_defaults(drive);
spin_unlock_irqrestore(&ide_lock, flags); spin_unlock_irqrestore(&ide_lock, flags);
up(&ide_setting_sem);
spin_lock(&drives_lock); spin_lock(&drives_lock);
list_del_init(&drive->list); list_del_init(&drive->list);
spin_unlock(&drives_lock); spin_unlock(&drives_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment