diff options
author | Martin K. Petersen | 2014-04-09 04:43:43 +0200 |
---|---|---|
committer | Jens Axboe | 2014-04-09 16:00:01 +0200 |
commit | b7aa84d9cb9f26da1a9312c3e39dbd1a3c25a426 (patch) | |
tree | 583b4d4a8cab1128b26c12e61a6cd598fcc268de /include/linux/bio.h | |
parent | drivers/block/loop.c: ratelimit error messages (diff) | |
download | kernel-qcow2-linux-b7aa84d9cb9f26da1a9312c3e39dbd1a3c25a426.tar.gz kernel-qcow2-linux-b7aa84d9cb9f26da1a9312c3e39dbd1a3c25a426.tar.xz kernel-qcow2-linux-b7aa84d9cb9f26da1a9312c3e39dbd1a3c25a426.zip |
block: Fix for_each_bvec()
Commit 4550dd6c6b062 introduced for_each_bvec() which iterates over each
bvec attached to a bio or bip. However, the macro fails to check bi_size
before dereferencing which can lead to crashes while counting/mapping
integrity scatterlist segments.
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Kent Overstreet <kmo@daterainc.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: <stable@vger.kernel.org> # v3.14+
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'include/linux/bio.h')
-rw-r--r-- | include/linux/bio.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/linux/bio.h b/include/linux/bio.h index 5a4d39b4686b..5aa372a7380c 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -216,9 +216,9 @@ static inline void bvec_iter_advance(struct bio_vec *bv, struct bvec_iter *iter, } #define for_each_bvec(bvl, bio_vec, iter, start) \ - for ((iter) = start; \ - (bvl) = bvec_iter_bvec((bio_vec), (iter)), \ - (iter).bi_size; \ + for (iter = (start); \ + (iter).bi_size && \ + ((bvl = bvec_iter_bvec((bio_vec), (iter))), 1); \ bvec_iter_advance((bio_vec), &(iter), (bvl).bv_len)) |