patch-2.2.4 linux/drivers/block/ll_rw_blk.c

Next file: linux/drivers/block/nbd.c
Previous file: linux/drivers/block/ide_modes.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.3/linux/drivers/block/ll_rw_blk.c linux/drivers/block/ll_rw_blk.c
@@ -392,8 +392,10 @@
 
 	lock_buffer(bh);
 
-	if (blk_size[major])
-		if (blk_size[major][MINOR(bh->b_rdev)] < (sector + count)>>1) {
+	if (blk_size[major]) {
+		unsigned long maxsector = (blk_size[major][MINOR(bh->b_rdev)] << 1) + 1;
+
+		if (maxsector < count || maxsector - count < sector) {
 			bh->b_state &= (1 << BH_Lock);
                         /* This may well happen - the kernel calls bread()
                            without checking the size of the device, e.g.,
@@ -406,6 +408,7 @@
                                blk_size[major][MINOR(bh->b_rdev)]);
 			goto end_io;
 		}
+	}
 
 	rw_ahead = 0;	/* normal case; gets changed below for READA/WRITEA */
 	switch (rw) {

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)