Skip to content

Commit

Permalink
block: fix the bio_vec array index out-of-bounds test
Browse files Browse the repository at this point in the history
Current bio_vec array index out-of-bounds test within
__end_that_request_first() does not seem correct.
It checks bio->bi_idx against bio->bi_vcnt, but the subsequent code
uses idx (which is, bio->bi_idx + next_idx) as the array index into
bio_vec array. This means that the test really make sense only at
the first iteration of !(nr_bytes >=bio->bi_size) case (when next_idx
== zero). Fix this by replacing bio->bi_idx with idx.
(This patch applies to 2.6.30-rc4.)

Signed-off-by: Kazuhisa Ichikawa <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Kazuhisa Ichikawa authored and Jens Axboe committed May 12, 2009
1 parent a4d7749 commit af498d7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1768,10 +1768,10 @@ static int __end_that_request_first(struct request *req, int error,
} else {
int idx = bio->bi_idx + next_idx;

if (unlikely(bio->bi_idx >= bio->bi_vcnt)) {
if (unlikely(idx >= bio->bi_vcnt)) {
blk_dump_rq_flags(req, "__end_that");
printk(KERN_ERR "%s: bio idx %d >= vcnt %d\n",
__func__, bio->bi_idx, bio->bi_vcnt);
__func__, idx, bio->bi_vcnt);
break;
}

Expand Down

0 comments on commit af498d7

Please sign in to comment.