Commit 5897f768 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz Committed by Jens Axboe

[PATCH] fix two IDE list_head problems

Fix two problems related to list_head's (there are more, wip).
Second bug was uncovered by wli's list_head debugging patch, thanks wli!

- Remove ata_unused list and use &idedefault_driver->drives only,
  fixes list corruption (ata_unused will be later ressurected for hotplug).

- Do not add same device twice to &idedefault_driver->drives, triggered
  by first calling ide_unregister_subdriver() and later ata_attach().
parent 35e57224
......@@ -462,7 +462,6 @@ static int ide_open (struct inode * inode, struct file * filp)
return -ENXIO;
}
static LIST_HEAD(ata_unused);
static spinlock_t drives_lock = SPIN_LOCK_UNLOCKED;
static spinlock_t drivers_lock = SPIN_LOCK_UNLOCKED;
static LIST_HEAD(drivers);
......@@ -1437,9 +1436,6 @@ int ata_attach(ide_drive_t *drive)
spin_unlock(&drivers_lock);
if(idedefault_driver.attach(drive) != 0)
panic("ide: default attach failed");
spin_lock(&drives_lock);
list_add_tail(&drive->list, &ata_unused);
spin_unlock(&drives_lock);
return 1;
}
......@@ -2383,8 +2379,8 @@ int ide_unregister_subdriver (ide_drive_t *drive)
spin_unlock_irqrestore(&ide_lock, flags);
spin_lock(&drives_lock);
list_del_init(&drive->list);
list_add(&drive->list, &drive->driver->drives);
spin_unlock(&drives_lock);
/* drive will be added to &idedefault_driver->drives in ata_attach() */
return 0;
}
......@@ -2407,9 +2403,9 @@ int ide_register_driver(ide_driver_t *driver)
list_add(&driver->drivers, &drivers);
spin_unlock(&drivers_lock);
spin_lock(&drives_lock);
INIT_LIST_HEAD(&list);
list_splice_init(&ata_unused, &list);
spin_lock(&drives_lock);
list_splice_init(&idedefault_driver.drives, &list);
spin_unlock(&drives_lock);
list_for_each_safe(list_loop, tmp_storage, &list) {
......
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