]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - block/bio.c
block: fix the DISCARD request merge
[mirror_ubuntu-bionic-kernel.git] / block / bio.c
index f411d634f62aef3c6e9e94ce1d09ff3bb6755069..9c64edac75d5055896516efc9dc28c43d41f673d 100644 (file)
@@ -156,7 +156,7 @@ out:
 
 unsigned int bvec_nr_vecs(unsigned short idx)
 {
-       return bvec_slabs[idx].nr_vecs;
+       return bvec_slabs[--idx].nr_vecs;
 }
 
 void bvec_free(mempool_t *pool, struct bio_vec *bv, unsigned int idx)
@@ -1316,8 +1316,11 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
                        }
                }
 
-               if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes)
+               if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes) {
+                       if (!map_data)
+                               __free_page(page);
                        break;
+               }
 
                len -= bytes;
                offset = 0;