]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - block/bio-integrity.c
USB: serial: mos7840: document MCS7810 detection hack
[linux.git] / block / bio-integrity.c
index 42536674020a2daf58681638762cad3255f6d677..fb95dbb21dd88516de76fc13138621f77bdf1457 100644 (file)
@@ -43,8 +43,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
        unsigned inline_vecs;
 
        if (!bs || !mempool_initialized(&bs->bio_integrity_pool)) {
-               bip = kmalloc(sizeof(struct bio_integrity_payload) +
-                             sizeof(struct bio_vec) * nr_vecs, gfp_mask);
+               bip = kmalloc(struct_size(bip, bip_inline_vecs, nr_vecs), gfp_mask);
                inline_vecs = nr_vecs;
        } else {
                bip = mempool_alloc(&bs->bio_integrity_pool, gfp_mask);
@@ -277,8 +276,12 @@ bool bio_integrity_prep(struct bio *bio)
                ret = bio_integrity_add_page(bio, virt_to_page(buf),
                                             bytes, offset);
 
-               if (ret == 0)
-                       return false;
+               if (ret == 0) {
+                       printk(KERN_ERR "could not attach integrity payload\n");
+                       kfree(buf);
+                       status = BLK_STS_RESOURCE;
+                       goto err_end_io;
+               }
 
                if (ret < bytes)
                        break;