patch-2.2.15 linux/fs/block_dev.c

Next file: linux/fs/buffer.c
Previous file: linux/fs/binfmt_elf.c
Back to the patch index
Back to the overall index

diff -u --new-file --recursive --exclude-from ../../exclude v2.2.14/fs/block_dev.c linux/fs/block_dev.c
@@ -92,6 +92,7 @@
 		      blocks = read_ahead[MAJOR(dev)] / (blocksize >> 9) / 2;
 		      if (block + blocks > size) blocks = size - block;
 		      if (blocks > NBUF) blocks=NBUF;
+		      if (!blocks) blocks = 1;
 		      for(i=1; i<blocks; i++)
 		      {
 		        bhlist[i] = getblk (dev, block+i, blocksize);
@@ -105,8 +106,10 @@
 		    ll_rw_block(READ, blocks, bhlist);
 		    for(i=1; i<blocks; i++) brelse(bhlist[i]);
 		    wait_on_buffer(bh);
-		    if (!buffer_uptodate(bh))
+		    if (!buffer_uptodate(bh)) {
+			  brelse(bh);
 			  return written ? written : -EIO;
+		    }
 		  };
 		};
 #endif

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