diff --git a/block/bio.c b/block/bio.c index 68972e3d3f5c..4c18a68913de 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1214,8 +1214,11 @@ struct bio *bio_copy_user_iov(struct request_queue *q, } } - if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes) + if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes) { + if (!map_data) + __free_page(page); break; + } len -= bytes; offset = 0;