DragonFlyBSD Kernel Audit
DF-1051 / 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
@@ -388,12 +388,13 @@
 	periph = (struct cam_periph *)ap->a_head.a_dev->si_drv1;
 	if (periph == NULL)
 		return (ENXIO);
+	if (cam_periph_acquire(periph) != CAM_REQ_CMP)
+		return (ENXIO);
 
 	/*
 	 * Don't allow access when we're running at a high securelevel.
 	 */
 	if (securelevel > 1) {
-		cam_periph_unlock(periph);
 		cam_periph_release(periph);
 		return(EPERM);
 	}