patch-2.0.36 linux/drivers/scsi/scsicam.c

Next file: linux/drivers/scsi/sd.c
Previous file: linux/drivers/scsi/scsi.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.0.35/linux/drivers/scsi/scsicam.c linux/drivers/scsi/scsicam.c
@@ -50,6 +50,7 @@
     struct buffer_head *bh;
     int ret_code;
     int size = disk->capacity;
+    unsigned long temp_cyl;
 
     if (!(bh = bread(MKDEV(MAJOR(dev), MINOR(dev)&~0xf), 0, 1024)))
 	return -1;
@@ -72,6 +73,11 @@
     if (ret_code || ip[0] > 255 || ip[1] > 63) {
 	 ip[0] = 64;
 	 ip[1] = 32;
+	 temp_cyl = size / (ip[0] * ip[1]);
+	 if (temp_cyl > 65534) {
+	      ip[0] = 255;
+	      ip[1] = 63;
+	 }
 	 ip[2] = size / (ip[0] * ip[1]);
     }
 
@@ -118,6 +124,8 @@
     	end_cyl = largest->end_cyl + ((largest->end_sector & 0xc0) << 2);
     	end_head = largest->end_head;
     	end_sector = largest->end_sector & 0x3f;
+
+        if( end_head + 1 == 0 || end_sector == 0 ) return -1;
 
 #ifdef DEBUG
 	printk ("scsicam_bios_param : end at h = %d, c = %d, s = %d\n",

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov