diff options
author | Tejun Heo <tj@kernel.org> | 2009-04-15 09:10:23 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-04-22 02:35:09 -0400 |
commit | 23c560a99d78bddf5c251bfa97bce19e4da4b3f3 (patch) | |
tree | 5c86aecb937ec49effaaf7cca526baf36c9c3eaf /lib/scatterlist.c | |
parent | 091069740304c979f957ceacec39c461d0192158 (diff) |
scatterlist: make sure sg_miter_next() doesn't return 0 sized mappings
Impact: fix not-so-critical but annoying bug
sg_miter_next() returns 0 sized mapping if there is an zero sized sg
entry in the list or at the end of each iteration. As the users
always check the ->length field, this bug shouldn't be critical other
than causing unnecessary iteration.
Fix it.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'lib/scatterlist.c')
-rw-r--r-- | lib/scatterlist.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/scatterlist.c b/lib/scatterlist.c index b7b449dafbe5..a295e404e908 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c | |||
@@ -347,9 +347,12 @@ bool sg_miter_next(struct sg_mapping_iter *miter) | |||
347 | sg_miter_stop(miter); | 347 | sg_miter_stop(miter); |
348 | 348 | ||
349 | /* get to the next sg if necessary. __offset is adjusted by stop */ | 349 | /* get to the next sg if necessary. __offset is adjusted by stop */ |
350 | if (miter->__offset == miter->__sg->length && --miter->__nents) { | 350 | while (miter->__offset == miter->__sg->length) { |
351 | miter->__sg = sg_next(miter->__sg); | 351 | if (--miter->__nents) { |
352 | miter->__offset = 0; | 352 | miter->__sg = sg_next(miter->__sg); |
353 | miter->__offset = 0; | ||
354 | } else | ||
355 | return false; | ||
353 | } | 356 | } |
354 | 357 | ||
355 | /* map the next page */ | 358 | /* map the next page */ |