diff options
author | mav <mav@FreeBSD.org> | 2012-10-10 19:32:40 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2012-10-10 19:32:40 +0000 |
commit | 81626f7faba37324662ae19bdabb40ba0f63e479 (patch) | |
tree | b3e712c664f05f88a2034de6cef59ca20fdd7cae /sys/cam | |
parent | 58b9ce6eb0728704b03d59b9ef08483a779ff3ab (diff) | |
download | FreeBSD-src-81626f7faba37324662ae19bdabb40ba0f63e479.zip FreeBSD-src-81626f7faba37324662ae19bdabb40ba0f63e479.tar.gz |
There are SCSI conditions that are not an errors. In those cases cderror()
returns zero while request status is not CAM_REQ_CMP. That could cause
partial device attach or other unexpected results.
Found by: Clang Static Analyzer
Diffstat (limited to 'sys/cam')
-rw-r--r-- | sys/cam/scsi/scsi_cd.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index bd42a28..d5d7156 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -1741,6 +1741,7 @@ cddone(struct cam_periph *periph, union ccb *done_ccb) * bytes. */ struct cd_params *cdp; + int error; cdp = &softc->params; @@ -1749,28 +1750,26 @@ cddone(struct cam_periph *periph, union ccb *done_ccb) cdp->disksize = scsi_4btoul (rdcap->addr) + 1; cdp->blksize = scsi_4btoul (rdcap->length); - if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { + /* + * Retry any UNIT ATTENTION type errors. They + * are expected at boot. + */ + if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP || + (error = cderror(done_ccb, CAM_RETRY_SELTO, + SF_RETRY_UA | SF_NO_PRINT)) == 0) { snprintf(announce_buf, sizeof(announce_buf), "cd present [%lu x %lu byte records]", cdp->disksize, (u_long)cdp->blksize); } else { - int error; - /* - * Retry any UNIT ATTENTION type errors. They - * are expected at boot. - */ - error = cderror(done_ccb, CAM_RETRY_SELTO, - SF_RETRY_UA | SF_NO_PRINT); if (error == ERESTART) { /* * A retry was scheuled, so * just return. */ return; - } else if (error != 0) { - + } else { int asc, ascq; int sense_key, error_code; int have_sense; |