[PATCH] sd: fix medium-removal bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit 409f3499a2cfcd1e9c2857c53af7fcce069f027f (scsi/sd: remove big
kernel lock) introduced a bug in the sd_release routine.  Medium
removal should be allowed when the number of open file references
drops to 0, not when it becomes non-zero.

This patch (as1414) adjusts the test to fix the bug.

Signed-off-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>

---

This patch needs to get into 2.6.36.  2.6.35 and earlier don't contain 
the buggy commit.



Index: usb-2.6/drivers/scsi/sd.c
===================================================================
--- usb-2.6.orig/drivers/scsi/sd.c
+++ usb-2.6/drivers/scsi/sd.c
@@ -870,7 +870,7 @@ static int sd_release(struct gendisk *di
 
 	SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_release\n"));
 
-	if (atomic_dec_return(&sdkp->openers) && sdev->removable) {
+	if (atomic_dec_return(&sdkp->openers) == 0 && sdev->removable) {
 		if (scsi_block_when_processing_errors(sdev))
 			scsi_set_medium_removal(sdev, SCSI_REMOVAL_ALLOW);
 	}

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux