diff options
Diffstat (limited to 'drivers/md/dm-verity.c')
-rw-r--r-- | drivers/md/dm-verity.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/md/dm-verity.c b/drivers/md/dm-verity.c index 796007a5e0e1..7a7bab8947ae 100644 --- a/drivers/md/dm-verity.c +++ b/drivers/md/dm-verity.c | |||
@@ -330,15 +330,17 @@ test_block_hash: | |||
330 | return r; | 330 | return r; |
331 | } | 331 | } |
332 | } | 332 | } |
333 | |||
334 | todo = 1 << v->data_dev_block_bits; | 333 | todo = 1 << v->data_dev_block_bits; |
335 | while (io->iter.bi_size) { | 334 | do { |
336 | u8 *page; | 335 | u8 *page; |
336 | unsigned len; | ||
337 | struct bio_vec bv = bio_iter_iovec(bio, io->iter); | 337 | struct bio_vec bv = bio_iter_iovec(bio, io->iter); |
338 | 338 | ||
339 | page = kmap_atomic(bv.bv_page); | 339 | page = kmap_atomic(bv.bv_page); |
340 | r = crypto_shash_update(desc, page + bv.bv_offset, | 340 | len = bv.bv_len; |
341 | bv.bv_len); | 341 | if (likely(len >= todo)) |
342 | len = todo; | ||
343 | r = crypto_shash_update(desc, page + bv.bv_offset, len); | ||
342 | kunmap_atomic(page); | 344 | kunmap_atomic(page); |
343 | 345 | ||
344 | if (r < 0) { | 346 | if (r < 0) { |
@@ -346,8 +348,9 @@ test_block_hash: | |||
346 | return r; | 348 | return r; |
347 | } | 349 | } |
348 | 350 | ||
349 | bio_advance_iter(bio, &io->iter, bv.bv_len); | 351 | bio_advance_iter(bio, &io->iter, len); |
350 | } | 352 | todo -= len; |
353 | } while (todo); | ||
351 | 354 | ||
352 | if (!v->version) { | 355 | if (!v->version) { |
353 | r = crypto_shash_update(desc, v->salt, v->salt_size); | 356 | r = crypto_shash_update(desc, v->salt, v->salt_size); |