Skip to content

Commit c26156b

Browse files
author
Jens Axboe
committed
block: hold extra reference to bio in blk_rq_map_user_iov()
If the size passed in is OK but we end up mapping too many segments, we call the unmap path directly like from IO completion. But from IO completion we have an extra reference to the bio, so this error case goes OOPS when it attempts to free and already free bio. Fix it by getting an extra reference to the bio before calling the unmap failure case. Reported-by: Petr Vandrovec <vandrove@vc.cvut.cz> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
1 parent 98ba403 commit c26156b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎block/blk-map.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
217217
return PTR_ERR(bio);
218218

219219
if (bio->bi_size != len) {
220+
/*
221+
* Grab an extra reference to this bio, as bio_unmap_user()
222+
* expects to be able to drop it twice as it happens on the
223+
* normal IO completion path
224+
*/
225+
bio_get(bio);
220226
bio_endio(bio, 0);
221227
bio_unmap_user(bio);
222228
return -EINVAL;

0 commit comments

Comments
 (0)