NFSv4.1: nfs4_fl_prepare_ds - fix bugs when the connect attempt fails
[firefly-linux-kernel-4.4.55.git] / fs / bio-integrity.c
index ca7b02dbf09d62d731faf3810033c14bb7f4339e..45e944fe52a6df63de0a6a1b5a0c674a527bf5c9 100644 (file)
@@ -97,9 +97,7 @@ void bio_integrity_free(struct bio *bio)
        struct bio_integrity_payload *bip = bio->bi_integrity;
        struct bio_set *bs = bio->bi_pool;
 
-       /* A cloned bio doesn't own the integrity metadata */
-       if (!bio_flagged(bio, BIO_CLONED) && !bio_flagged(bio, BIO_FS_INTEGRITY)
-           && bip->bip_buf != NULL)
+       if (bip->bip_owns_buf)
                kfree(bip->bip_buf);
 
        if (bs) {
@@ -386,6 +384,7 @@ int bio_integrity_prep(struct bio *bio)
                return -EIO;
        }
 
+       bip->bip_owns_buf = 1;
        bip->bip_buf = buf;
        bip->bip_size = len;
        bip->bip_sector = bio->bi_sector;
@@ -735,7 +734,7 @@ void bioset_integrity_free(struct bio_set *bs)
                mempool_destroy(bs->bio_integrity_pool);
 
        if (bs->bvec_integrity_pool)
-               mempool_destroy(bs->bio_integrity_pool);
+               mempool_destroy(bs->bvec_integrity_pool);
 }
 EXPORT_SYMBOL(bioset_integrity_free);