Commit 95d78c28 authored by Vitaly Mayatskikh's avatar Vitaly Mayatskikh Committed by Al Viro

fix unbalanced page refcounting in bio_map_user_iov

bio_map_user_iov and bio_unmap_user do unbalanced pages refcounting if
IO vector has small consecutive buffers belonging to the same page.
bio_add_pc_page merges them into one, but the page reference is never

Signed-off-by: default avatarVitaly Mayatskikh <>
Signed-off-by: default avatarAl Viro <>
parent 899f0429
......@@ -1383,6 +1383,7 @@ struct bio *bio_map_user_iov(struct request_queue *q,
offset = offset_in_page(uaddr);
for (j = cur_page; j < page_limit; j++) {
unsigned int bytes = PAGE_SIZE - offset;
unsigned short prev_bi_vcnt = bio->bi_vcnt;
if (len <= 0)
......@@ -1397,6 +1398,13 @@ struct bio *bio_map_user_iov(struct request_queue *q,
* check if vector was merged with previous
* drop page reference if needed
if (bio->bi_vcnt == prev_bi_vcnt)
len -= bytes;
offset = 0;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment