Skip to contentSkip to conversation

ide: fix locking in drive_release_dev()

PATCH New Bartlomiej Zolnierkiewicz 1 participant 1 message Feb 23, 2009 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ide: fix locking in drive_release_dev()

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: fix locking in drive_release_dev()

* Request queue cleanup should happen before freeing drive->id and marking device as non-present. Fix it.

* Remove superfluous hwif->lock acquiring/releasing.

---
I noticed this while investigating the host driver removal issue -- lets also fix/test this one while we are at it...

 drivers/ide/ide-probe.c |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/ide/ide-probe.c +4 -8
Index: b/drivers/ide/ide-probe.c
===================================================================
@@ -937,20 +937,16 @@ EXPORT_SYMBOL_GPL(ide_init_disk);
 static void drive_release_dev (struct device *dev)
 {
 	ide_drive_t *drive = container_of(dev, ide_drive_t, gendev);
-	ide_hwif_t *hwif = drive->hwif;
 
 	ide_proc_unregister_device(drive);
 
-	spin_lock_irq(&hwif->lock);
+	blk_cleanup_queue(drive->queue);
+	drive->queue = NULL;
+
 	kfree(drive->id);
 	drive->id = NULL;
+
 	drive->dev_flags &= ~IDE_DFLAG_PRESENT;
-	/* Messed up locking ... */
-	spin_unlock_irq(&hwif->lock);
-	blk_cleanup_queue(drive->queue);
-	spin_lock_irq(&hwif->lock);
-	drive->queue = NULL;
-	spin_unlock_irq(&hwif->lock);
 
 	complete(&drive->gendev_rel_comp);
 }