diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index c31b10be662d..bc16d8be8985 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -1865,9 +1865,23 @@ dasetgeom(struct cam_periph *periph, uint32_t block_len, uint64_t maxsector) ccg.secs_per_track = 0; ccg.cylinders = 0; xpt_action((union ccb*)&ccg); - dp->heads = ccg.heads; - dp->secs_per_track = ccg.secs_per_track; - dp->cylinders = ccg.cylinders; + if ((ccg.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { + /* + * We don't know what went wrong here- but just pick + * a geometry so we don't have nasty things like divide + * by zero. + */ + dp->heads = 255; + dp->secs_per_track = 255; + dp->cylinders = dp->sectors / (255 * 255); + if (dp->cylinders == 0) { + dp->cylinders = 1; + } + } else { + dp->heads = ccg.heads; + dp->secs_per_track = ccg.secs_per_track; + dp->cylinders = ccg.cylinders; + } } static void