Commit d0b7fcbf authored by Jens Axboe's avatar Jens Axboe Committed by Linus Torvalds

[PATCH] bio: fix leak in failure case in bio_copy_user()

There's a leak in the error case in bio_copy_user().  If we fail
allocating a page or adding a page to the bio, we will leak the bio map
data. 
Signed-off-by: default avatarJens Axboe <axboe@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 8c86608b
......@@ -461,11 +461,10 @@ struct bio *bio_copy_user(request_queue_t *q, unsigned long uaddr,
bmd->userptr = (void __user *) uaddr;
ret = -ENOMEM;
bio = bio_alloc(GFP_KERNEL, end - start);
if (!bio) {
bio_free_map_data(bmd);
return ERR_PTR(-ENOMEM);
}
if (!bio)
goto out_bmd;
bio->bi_rw |= (!write_to_vm << BIO_RW);
......@@ -519,6 +518,8 @@ struct bio *bio_copy_user(request_queue_t *q, unsigned long uaddr,
__free_page(bvec->bv_page);
bio_put(bio);
out_bmd:
bio_free_map_data(bmd);
return ERR_PTR(ret);
}
......
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