patch-2.4.21 linux-2.4.21/drivers/cdrom/cdu31a.c

Next file: linux-2.4.21/drivers/char/Config.in
Previous file: linux-2.4.21/drivers/bluetooth/hci_usb.h
Back to the patch index
Back to the overall index

diff -urN linux-2.4.20/drivers/cdrom/cdu31a.c linux-2.4.21/drivers/cdrom/cdu31a.c
@@ -1361,6 +1361,8 @@
 	res_reg[0] = 0;
 	res_reg[1] = 0;
 	*res_size = 0;
+	/* Make sure that bytesleft doesn't exceed the buffer size */
+	if (nblocks > 4) nblocks = 4;
 	bytesleft = nblocks * 512;
 	offset = 0;
 
@@ -1384,9 +1386,9 @@
 			       readahead_buffer + (2048 -
 						   readahead_dataleft),
 			       readahead_dataleft);
-			readahead_dataleft = 0;
 			bytesleft -= readahead_dataleft;
 			offset += readahead_dataleft;
+			readahead_dataleft = 0;
 		} else {
 			/* The readahead will fill the whole buffer, get the data
 			   and return. */

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