Skip to content

Commit a3761c3

Browse files
Jérôme Glisseaxboe
authored andcommitted
block: do not leak memory in bio_copy_user_iov()
When bio_add_pc_page() fails in bio_copy_user_iov() we should free the page we just allocated otherwise we are leaking it. Cc: [email protected] Cc: Linus Torvalds <[email protected]> Cc: [email protected] Reviewed-by: Chaitanya Kulkarni <[email protected]> Signed-off-by: Jérôme Glisse <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent b2b3a70 commit a3761c3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

block/bio.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,8 +1298,11 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
12981298
}
12991299
}
13001300

1301-
if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes)
1301+
if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes) {
1302+
if (!map_data)
1303+
__free_page(page);
13021304
break;
1305+
}
13031306

13041307
len -= bytes;
13051308
offset = 0;

0 commit comments

Comments
 (0)