Commit af498d7fa3e786f52650819a56e117ed9a40920c

Authored by Kazuhisa Ichikawa
Committed by Jens Axboe
1 parent a4d7749be5

block: fix the bio_vec array index out-of-bounds test

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 <ki@epsilou.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>

Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff

... ... @@ -1768,10 +1768,10 @@
1768 1768 } else {
1769 1769 int idx = bio->bi_idx + next_idx;
1770 1770  
1771   - if (unlikely(bio->bi_idx >= bio->bi_vcnt)) {
  1771 + if (unlikely(idx >= bio->bi_vcnt)) {
1772 1772 blk_dump_rq_flags(req, "__end_that");
1773 1773 printk(KERN_ERR "%s: bio idx %d >= vcnt %d\n",
1774   - __func__, bio->bi_idx, bio->bi_vcnt);
  1774 + __func__, idx, bio->bi_vcnt);
1775 1775 break;
1776 1776 }
1777 1777