diff options
author | Andrew Morton <akpm@osdl.org> | 2005-10-30 18:03:15 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-10-30 20:37:27 -0500 |
commit | a3e713b5fdd0e54c2e3c8909ccde2a98839e3a52 (patch) | |
tree | c42c037f239de130f2efe30777df9688bf4dd022 | |
parent | 727a53bd535fe3bde644ac346db27456ad964083 (diff) |
[PATCH] __bread oops fix
If a filesystem passes an idiotic blocksize into bread(), __getblk_slow() will
warn and will return NULL. We have a report (from Hubert Tonneau
<hubert.tonneau@fullpliant.org>) of isofs_fill_super() doing this (passing in
a silly block size) against an unplugged CDROM drive.
But a couple of __getblk_slow() callers forgot to check for the NULL bh, hence
oops.
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | fs/buffer.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/buffer.c b/fs/buffer.c index 75cac9ada026..35fa34977e81 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -1478,8 +1478,10 @@ EXPORT_SYMBOL(__getblk); | |||
1478 | void __breadahead(struct block_device *bdev, sector_t block, int size) | 1478 | void __breadahead(struct block_device *bdev, sector_t block, int size) |
1479 | { | 1479 | { |
1480 | struct buffer_head *bh = __getblk(bdev, block, size); | 1480 | struct buffer_head *bh = __getblk(bdev, block, size); |
1481 | ll_rw_block(READA, 1, &bh); | 1481 | if (likely(bh)) { |
1482 | brelse(bh); | 1482 | ll_rw_block(READA, 1, &bh); |
1483 | brelse(bh); | ||
1484 | } | ||
1483 | } | 1485 | } |
1484 | EXPORT_SYMBOL(__breadahead); | 1486 | EXPORT_SYMBOL(__breadahead); |
1485 | 1487 | ||
@@ -1497,7 +1499,7 @@ __bread(struct block_device *bdev, sector_t block, int size) | |||
1497 | { | 1499 | { |
1498 | struct buffer_head *bh = __getblk(bdev, block, size); | 1500 | struct buffer_head *bh = __getblk(bdev, block, size); |
1499 | 1501 | ||
1500 | if (!buffer_uptodate(bh)) | 1502 | if (likely(bh) && !buffer_uptodate(bh)) |
1501 | bh = __bread_slow(bh); | 1503 | bh = __bread_slow(bh); |
1502 | return bh; | 1504 | return bh; |
1503 | } | 1505 | } |