diff options
Diffstat (limited to 'fs/bio.c')
-rw-r--r-- | fs/bio.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -1045,12 +1045,22 @@ static int __bio_copy_iov(struct bio *bio, struct bio_vec *iovecs, | |||
1045 | int bio_uncopy_user(struct bio *bio) | 1045 | int bio_uncopy_user(struct bio *bio) |
1046 | { | 1046 | { |
1047 | struct bio_map_data *bmd = bio->bi_private; | 1047 | struct bio_map_data *bmd = bio->bi_private; |
1048 | int ret = 0; | 1048 | struct bio_vec *bvec; |
1049 | int ret = 0, i; | ||
1049 | 1050 | ||
1050 | if (!bio_flagged(bio, BIO_NULL_MAPPED)) | 1051 | if (!bio_flagged(bio, BIO_NULL_MAPPED)) { |
1051 | ret = __bio_copy_iov(bio, bmd->iovecs, bmd->sgvecs, | 1052 | /* |
1052 | bmd->nr_sgvecs, bio_data_dir(bio) == READ, | 1053 | * if we're in a workqueue, the request is orphaned, so |
1053 | 0, bmd->is_our_pages); | 1054 | * don't copy into a random user address space, just free. |
1055 | */ | ||
1056 | if (current->mm) | ||
1057 | ret = __bio_copy_iov(bio, bmd->iovecs, bmd->sgvecs, | ||
1058 | bmd->nr_sgvecs, bio_data_dir(bio) == READ, | ||
1059 | 0, bmd->is_our_pages); | ||
1060 | else if (bmd->is_our_pages) | ||
1061 | bio_for_each_segment_all(bvec, bio, i) | ||
1062 | __free_page(bvec->bv_page); | ||
1063 | } | ||
1054 | bio_free_map_data(bmd); | 1064 | bio_free_map_data(bmd); |
1055 | bio_put(bio); | 1065 | bio_put(bio); |
1056 | return ret; | 1066 | return ret; |