From bd6d02e7e9c7d34a69e2da2384e4da0b8dbb03b2 Mon Sep 17 00:00:00 2001 From: Andrew Thompson Date: Mon, 2 Nov 2009 23:30:15 +0000 Subject: [PATCH] Provide the same sanity check on the sector size in dagetcapacity as when the disk is first probed. dagetcapacity is called whenever the disk is opened from geom via d_open(), a zero sector size will cause geom to panic later on. --- sys/cam/scsi/scsi_da.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 8f740dcdfad2..32ca51bb379c 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -1948,8 +1948,15 @@ dagetcapacity(struct cam_periph *periph) done: - if (error == 0) - dasetgeom(periph, block_len, maxsector); + if (error == 0) { + if (block_len >= MAXPHYS || block_len == 0) { + xpt_print(periph->path, + "unsupportable block size %ju\n", + (uintmax_t) block_len); + error = EINVAL; + } else + dasetgeom(periph, block_len, maxsector); + } xpt_release_ccb(ccb);