When bio_add_page() fails in bio_copy_kern(), the allocated page is not freed before breaking the loop, leading to a memory leak. Fixes: 42d2683a2704 ("block: simplify bio_map_kern") Signed-off-by: Yang Xiuwei diff --git a/block/blk-map.c b/block/blk-map.c index 53bdd100aa4b..ed0ff4e77833 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -398,8 +398,10 @@ static struct bio *bio_copy_kern(struct request *rq, void *data, unsigned int le if (op_is_write(op)) memcpy(page_address(page), p, bytes); - if (bio_add_page(bio, page, bytes, 0) < bytes) + if (bio_add_page(bio, page, bytes, 0) < bytes) { + __free_page(page); break; + } len -= bytes; p += bytes; -- 2.25.1