]> 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 1b633a3526d4f239fc22694b61285cbf7665f1d8..fb95dbb21dd88516de76fc13138621f77bdf1457 100644 (file)
@@ -1,23 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * bio-integrity.c - bio data integrity extensions
  *
  * Copyright (C) 2007, 2008, 2009 Oracle Corporation
  * Written by: Martin K. Petersen <martin.petersen@oracle.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version
- * 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING.  If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
- * USA.
- *
  */
 
 #include <linux/blkdev.h>
@@ -57,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);
@@ -291,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;