summaryrefslogtreecommitdiffstats
path: root/share/examples/scsi_target
diff options
context:
space:
mode:
authormjacob <mjacob@FreeBSD.org>2000-07-18 04:39:36 +0000
committermjacob <mjacob@FreeBSD.org>2000-07-18 04:39:36 +0000
commit94d46e7245fe676507c507a39b94cc6e10f076d3 (patch)
tree5a6d0c982a5592ac0600b93bd9e3a7bbe3ca149e /share/examples/scsi_target
parent1fae1d72731d7063a75e01c401723ded3b761515 (diff)
downloadFreeBSD-src-94d46e7245fe676507c507a39b94cc6e10f076d3.zip
FreeBSD-src-94d46e7245fe676507c507a39b94cc6e10f076d3.tar.gz
Don't get stuck in a loop calling exit from an atexit routine. Clean
up cam_fill_ctio usage to passed atio flags. Clear periph_priv area of new ctio so if the kernel is dumb enough to look at them (this is a SECURITY hole) the panic will be obvious instead of subtle.
Diffstat (limited to 'share/examples/scsi_target')
-rw-r--r--share/examples/scsi_target/scsi_target.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/share/examples/scsi_target/scsi_target.c b/share/examples/scsi_target/scsi_target.c
index ae5a8e4..c240686 100644
--- a/share/examples/scsi_target/scsi_target.c
+++ b/share/examples/scsi_target/scsi_target.c
@@ -184,12 +184,9 @@ cleanup()
(void) ioctl(targfd, TARGIODEBUG, &debug);
}
close(targfd);
-
if (ioctl(targctlfd, TARGCTLIOFREEUNIT, &alloc_unit) == -1) {
perror("TARGCTLIOFREEUNIT");
- exit(EX_SOFTWARE);
}
-
close(targctlfd);
}
@@ -326,18 +323,22 @@ handle_exception()
}
bzero(&ccb, sizeof(ccb));
- cam_fill_ctio(&ccb.csio, /*retries*/2,
+ cam_fill_ctio(&ccb.csio,
+ /*retries*/2,
/*cbfcnp*/NULL,
- /*flags*/CAM_DIR_NONE
- | (atio.ccb_h.flags & CAM_TAG_ACTION_VALID)
- | CAM_SEND_STATUS,
- /*tag_action*/MSG_SIMPLE_Q_TAG,
+ CAM_DIR_NONE | CAM_SEND_STATUS,
+ (atio.ccb_h.flags & CAM_TAG_ACTION_VALID)?
+ MSG_SIMPLE_Q_TAG : 0,
atio.tag_id,
atio.init_id,
SCSI_STATUS_CHECK_COND,
/*data_ptr*/NULL,
/*dxfer_len*/0,
/*timeout*/5 * 1000);
+ /*
+ * Make sure that periph_priv pointers are clean.
+ */
+ bzero(&ccb.ccb_h.periph_priv, sizeof ccb.ccb_h.periph_priv);
if (ioctl(targfd, TARGIOCCOMMAND, &ccb) == -1) {
perror("TARGIOCCOMMAND");
OpenPOWER on IntegriCloud