]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
block/bio-integrity: use struct_size() in kmalloc()
authorJackie Liu <liuyun01@kylinos.cn>
Wed, 15 May 2019 08:52:19 +0000 (16:52 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 16 May 2019 14:48:48 +0000 (08:48 -0600)
Use the new struct_size() helper to keep code simple.

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio-integrity.c

index 42536674020a2daf58681638762cad3255f6d677..4db620849515f7c42843e4825a89918687becd28 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);