Do not advance pio past bio end - this should not happen
but try to catch and log it as an error.

https://virtuozzo.atlassian.net/browse/VSTOR-91821
Signed-off-by: Alexander Atanasov <alexander.atana...@virtuozzo.com>
---
 drivers/md/dm-ploop-map.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 7d531564b24c..fc2d99c3a8d0 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -271,8 +271,17 @@ static void ploop_pio_advance(struct pio *pio, unsigned 
int bytes)
 
        if (op_is_discard(pio->bi_op))
                iter->bi_size -= bytes;
-       else
+       else {
+               if (bytes > iter->bi_size) {
+                       struct ploop *ploop = pio->ploop;
+
+                       PL_ERR("advance past bio end\n");
+                       bytes = iter->bi_size;
+                       if (!bytes)
+                               return;
+               }
                bvec_iter_advance(pio->bi_io_vec, iter, bytes);
+       }
 }
 
 static struct pio *ploop_split_and_chain_pio(struct ploop *ploop,
-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to