Return early on error, and add an unlikely annotation for that case.
Unified · Split
| @@ -873,20 +873,19 @@ static int __bio_iov_bvec_add_pages(struct bio *bio, struct iov_iter *iter) · 872 unmodified lines | |||
| 873 | len = min_t(size_t, bv->bv_len - iter->iov_offset, iter->count); | 873 | len = min_t(size_t, bv->bv_len - iter->iov_offset, iter->count); |
| 874 | size = bio_add_page(bio, bv->bv_page, len, | 874 | size = bio_add_page(bio, bv->bv_page, len, |
| 875 | bv->bv_offset + iter->iov_offset); | 875 | bv->bv_offset + iter->iov_offset); |
| 876 | if (size == len) { | 876 | if (unlikely(size != len)) |
| 877 | if (!bio_flagged(bio, BIO_NO_PAGE_REF)) { | 877 | return -EINVAL; |
| 878 | struct page *page; | ||
| 879 | int i; | ||
| 880 | 878 | ||
| 881 | mp_bvec_for_each_page(page, bv, i) | 879 | if (!bio_flagged(bio, BIO_NO_PAGE_REF)) { |
| 882 | get_page(page); | 880 | struct page *page; |
| 883 | } | 881 | int i; |
| 884 | 882 | ||
| 885 | iov_iter_advance(iter, size); | 883 | mp_bvec_for_each_page(page, bv, i) |
| 886 | return 0; | 884 | get_page(page); |
| 887 | } | 885 | } |
| 888 | 886 | ||
| 889 | return -EINVAL; | 887 | iov_iter_advance(iter, size); |
| 888 | return 0; | ||
| 890 | } | 889 | } |
| 891 | 890 | ||
| 892 | #define PAGE_PTRS_PER_BVEC (sizeof(struct bio_vec) / sizeof(struct page *)) | 891 | #define PAGE_PTRS_PER_BVEC (sizeof(struct bio_vec) / sizeof(struct page *)) |