DragonFlyBSD Kernel Audit
DF-1054 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/bus/cam/scsi/scsi_sg.c b/sys/bus/cam/scsi/scsi_sg.c
--- a/sys/bus/cam/scsi/scsi_sg.c
+++ b/sys/bus/cam/scsi/scsi_sg.c
@@ -786,6 +786,11 @@
 			break;
 	}
 	if (rdwr == NULL) {
+		/* DF-1054: device removed -> don't block forever */
+		if (sc->flags & SG_FLAG_INVALID) {
+			cam_periph_unlock(periph);
+			return (ENXIO);
+		}
 		cam_periph_unlock(periph);
 		if (tsleep(&hstat, PCATCH, "sgnull", 0) == ERESTART)
 			return(EAGAIN);