diff options
| author | Kees Cook <kees@kernel.org> | 2026-02-20 23:49:23 -0800 |
|---|---|---|
| committer | Kees Cook <kees@kernel.org> | 2026-02-21 01:02:28 -0800 |
| commit | 69050f8d6d075dc01af7a5f2f550a8067510366f (patch) | |
| tree | bb265f94d9dfa7876c06a5d9f88673d496a15341 /block | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
| download | linux-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz linux-69050f8d6d075dc01af7a5f2f550a8067510366f.zip | |
treewide: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Coccinelle script from
scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to
avoid scalar types (which need careful case-by-case checking), and
instead replace kmalloc-family calls that allocate struct or union
object instances:
Single allocations: kmalloc(sizeof(TYPE), ...)
are replaced with: kmalloc_obj(TYPE, ...)
Array allocations: kmalloc_array(COUNT, sizeof(TYPE), ...)
are replaced with: kmalloc_objs(TYPE, COUNT, ...)
Flex array allocations: kmalloc(struct_size(PTR, FAM, COUNT), ...)
are replaced with: kmalloc_flex(*PTR, FAM, COUNT, ...)
(where TYPE may also be *VAR)
The resulting allocations no longer return "void *", instead returning
"TYPE *".
Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'block')
| -rw-r--r-- | block/bfq-cgroup.c | 2 | ||||
| -rw-r--r-- | block/bfq-iosched.c | 6 | ||||
| -rw-r--r-- | block/bio-integrity.c | 4 | ||||
| -rw-r--r-- | block/bio.c | 2 | ||||
| -rw-r--r-- | block/blk-cgroup.c | 2 | ||||
| -rw-r--r-- | block/blk-crypto-fallback.c | 9 | ||||
| -rw-r--r-- | block/blk-crypto-profile.c | 7 | ||||
| -rw-r--r-- | block/blk-crypto-sysfs.c | 2 | ||||
| -rw-r--r-- | block/blk-iocost.c | 4 | ||||
| -rw-r--r-- | block/blk-iolatency.c | 2 | ||||
| -rw-r--r-- | block/blk-ioprio.c | 2 | ||||
| -rw-r--r-- | block/blk-map.c | 2 | ||||
| -rw-r--r-- | block/blk-mq-sched.c | 4 | ||||
| -rw-r--r-- | block/blk-mq.c | 4 | ||||
| -rw-r--r-- | block/blk-stat.c | 7 | ||||
| -rw-r--r-- | block/blk-wbt.c | 2 | ||||
| -rw-r--r-- | block/blk-zoned.c | 4 | ||||
| -rw-r--r-- | block/bsg-lib.c | 2 | ||||
| -rw-r--r-- | block/bsg.c | 2 | ||||
| -rw-r--r-- | block/disk-events.c | 2 | ||||
| -rw-r--r-- | block/fops.c | 3 | ||||
| -rw-r--r-- | block/genhd.c | 4 | ||||
| -rw-r--r-- | block/holder.c | 2 | ||||
| -rw-r--r-- | block/partitions/aix.c | 2 | ||||
| -rw-r--r-- | block/partitions/cmdline.c | 4 | ||||
| -rw-r--r-- | block/partitions/core.c | 2 | ||||
| -rw-r--r-- | block/partitions/efi.c | 2 | ||||
| -rw-r--r-- | block/partitions/ibm.c | 6 | ||||
| -rw-r--r-- | block/partitions/ldm.c | 10 | ||||
| -rw-r--r-- | block/sed-opal.c | 4 |
30 files changed, 53 insertions, 57 deletions
diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index 6a75fe1c7a5c0..ac83b06687640 100644 --- a/block/bfq-cgroup.c +++ b/block/bfq-cgroup.c @@ -494,7 +494,7 @@ static struct blkcg_policy_data *bfq_cpd_alloc(gfp_t gfp) { struct bfq_group_data *bgd; - bgd = kzalloc(sizeof(*bgd), gfp); + bgd = kzalloc_obj(*bgd, gfp); if (!bgd) return NULL; diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index b180ce5839518..141c602d5e858 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -606,7 +606,7 @@ retry: spin_unlock_irq(&bfqd->lock); if (entities != inline_entities) kfree(entities); - entities = kmalloc_array(depth, sizeof(*entities), GFP_NOIO); + entities = kmalloc_objs(*entities, depth, GFP_NOIO); if (!entities) return false; alloc_depth = depth; @@ -938,8 +938,8 @@ void bfq_weights_tree_add(struct bfq_queue *bfqq) } } - bfqq->weight_counter = kzalloc(sizeof(struct bfq_weight_counter), - GFP_ATOMIC); + bfqq->weight_counter = kzalloc_obj(struct bfq_weight_counter, + GFP_ATOMIC); /* * In the unlucky event of an allocation failure, we just diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 09eeaf6e74b8f..dc2e771f11aeb 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -97,7 +97,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio, if (WARN_ON_ONCE(bio_has_crypt_ctx(bio))) return ERR_PTR(-EOPNOTSUPP); - bia = kmalloc(struct_size(bia, bvecs, nr_vecs), gfp_mask); + bia = kmalloc_flex(*bia, bvecs, nr_vecs, gfp_mask); if (unlikely(!bia)) return ERR_PTR(-ENOMEM); bio_integrity_init(bio, &bia->bip, bia->bvecs, nr_vecs); @@ -322,7 +322,7 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter) if (nr_vecs > BIO_MAX_VECS) return -E2BIG; if (nr_vecs > UIO_FASTIOV) { - bvec = kcalloc(nr_vecs, sizeof(*bvec), GFP_KERNEL); + bvec = kzalloc_objs(*bvec, nr_vecs, GFP_KERNEL); if (!bvec) return -ENOMEM; pages = NULL; diff --git a/block/bio.c b/block/bio.c index 8203bb7455a9f..c8e14c330a352 100644 --- a/block/bio.c +++ b/block/bio.c @@ -84,7 +84,7 @@ static DEFINE_XARRAY(bio_slabs); static struct bio_slab *create_bio_slab(unsigned int size) { - struct bio_slab *bslab = kzalloc(sizeof(*bslab), GFP_KERNEL); + struct bio_slab *bslab = kzalloc_obj(*bslab, GFP_KERNEL); if (!bslab) return NULL; diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 3cffb68ba5d87..de609a3e02289 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1417,7 +1417,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css) if (!parent_css) { blkcg = &blkcg_root; } else { - blkcg = kzalloc(sizeof(*blkcg), GFP_KERNEL); + blkcg = kzalloc_obj(*blkcg, GFP_KERNEL); if (!blkcg) goto unlock; } diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c index a331b061dbf4d..9a05abe8d43fd 100644 --- a/block/blk-crypto-fallback.c +++ b/block/blk-crypto-fallback.c @@ -546,8 +546,8 @@ static int blk_crypto_fallback_init(void) goto out; /* Dynamic allocation is needed because of lockdep_register_key(). */ - blk_crypto_fallback_profile = - kzalloc(sizeof(*blk_crypto_fallback_profile), GFP_KERNEL); + blk_crypto_fallback_profile = kzalloc_obj(*blk_crypto_fallback_profile, + GFP_KERNEL); if (!blk_crypto_fallback_profile) { err = -ENOMEM; goto fail_free_bioset; @@ -574,9 +574,8 @@ static int blk_crypto_fallback_init(void) if (!blk_crypto_wq) goto fail_destroy_profile; - blk_crypto_keyslots = kcalloc(blk_crypto_num_keyslots, - sizeof(blk_crypto_keyslots[0]), - GFP_KERNEL); + blk_crypto_keyslots = kzalloc_objs(blk_crypto_keyslots[0], + blk_crypto_num_keyslots, GFP_KERNEL); if (!blk_crypto_keyslots) goto fail_free_wq; diff --git a/block/blk-crypto-profile.c b/block/blk-crypto-profile.c index 81918f6e0caea..58032fd7faffd 100644 --- a/block/blk-crypto-profile.c +++ b/block/blk-crypto-profile.c @@ -93,8 +93,7 @@ int blk_crypto_profile_init(struct blk_crypto_profile *profile, /* Initialize keyslot management data. */ - profile->slots = kvcalloc(num_slots, sizeof(profile->slots[0]), - GFP_KERNEL); + profile->slots = kvzalloc_objs(profile->slots[0], num_slots, GFP_KERNEL); if (!profile->slots) goto err_destroy; @@ -121,8 +120,8 @@ int blk_crypto_profile_init(struct blk_crypto_profile *profile, profile->log_slot_ht_size = ilog2(slot_hashtable_size); profile->slot_hashtable = - kvmalloc_array(slot_hashtable_size, - sizeof(profile->slot_hashtable[0]), GFP_KERNEL); + kvmalloc_objs(profile->slot_hashtable[0], slot_hashtable_size, + GFP_KERNEL); if (!profile->slot_hashtable) goto err_destroy; for (i = 0; i < slot_hashtable_size; i++) diff --git a/block/blk-crypto-sysfs.c b/block/blk-crypto-sysfs.c index e832f403f2002..e6c76d672829a 100644 --- a/block/blk-crypto-sysfs.c +++ b/block/blk-crypto-sysfs.c @@ -170,7 +170,7 @@ int blk_crypto_sysfs_register(struct gendisk *disk) if (!q->crypto_profile) return 0; - obj = kzalloc(sizeof(*obj), GFP_KERNEL); + obj = kzalloc_obj(*obj, GFP_KERNEL); if (!obj) return -ENOMEM; obj->profile = q->crypto_profile; diff --git a/block/blk-iocost.c b/block/blk-iocost.c index ef543d163d469..32faf0a56bd37 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -2882,7 +2882,7 @@ static int blk_iocost_init(struct gendisk *disk) struct ioc *ioc; int i, cpu, ret; - ioc = kzalloc(sizeof(*ioc), GFP_KERNEL); + ioc = kzalloc_obj(*ioc, GFP_KERNEL); if (!ioc) return -ENOMEM; @@ -2946,7 +2946,7 @@ static struct blkcg_policy_data *ioc_cpd_alloc(gfp_t gfp) { struct ioc_cgrp *iocc; - iocc = kzalloc(sizeof(struct ioc_cgrp), gfp); + iocc = kzalloc_obj(struct ioc_cgrp, gfp); if (!iocc) return NULL; diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index f7434278cd29c..609a71476bff4 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -760,7 +760,7 @@ static int blk_iolatency_init(struct gendisk *disk) struct blk_iolatency *blkiolat; int ret; - blkiolat = kzalloc(sizeof(*blkiolat), GFP_KERNEL); + blkiolat = kzalloc_obj(*blkiolat, GFP_KERNEL); if (!blkiolat) return -ENOMEM; diff --git a/block/blk-ioprio.c b/block/blk-ioprio.c index 13659dc15c3ff..8fa8bca350629 100644 --- a/block/blk-ioprio.c +++ b/block/blk-ioprio.c @@ -99,7 +99,7 @@ static struct blkcg_policy_data *ioprio_alloc_cpd(gfp_t gfp) { struct ioprio_blkcg *blkcg; - blkcg = kzalloc(sizeof(*blkcg), gfp); + blkcg = kzalloc_obj(*blkcg, gfp); if (!blkcg) return NULL; blkcg->prio_policy = POLICY_NO_CHANGE; diff --git a/block/blk-map.c b/block/blk-map.c index 4533094d94583..53bdd100aa4ba 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -26,7 +26,7 @@ static struct bio_map_data *bio_alloc_map_data(struct iov_iter *data, if (data->nr_segs > UIO_MAXIOV) return NULL; - bmd = kmalloc(struct_size(bmd, iov, data->nr_segs), gfp_mask); + bmd = kmalloc_flex(*bmd, iov, data->nr_segs, gfp_mask); if (!bmd) return NULL; bmd->iter = *data; diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index 97c3c8f45a9b7..0d085a53f0d7c 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -489,7 +489,7 @@ int blk_mq_alloc_sched_ctx_batch(struct xarray *elv_tbl, lockdep_assert_held_write(&set->update_nr_hwq_lock); list_for_each_entry(q, &set->tag_list, tag_set_list) { - ctx = kzalloc(sizeof(struct elv_change_ctx), GFP_KERNEL); + ctx = kzalloc_obj(struct elv_change_ctx, GFP_KERNEL); if (!ctx) return -ENOMEM; @@ -514,7 +514,7 @@ struct elevator_tags *blk_mq_alloc_sched_tags(struct blk_mq_tag_set *set, else nr_tags = nr_hw_queues; - et = kmalloc(struct_size(et, tags, nr_tags), gfp); + et = kmalloc_flex(*et, tags, nr_tags, gfp); if (!et) return NULL; diff --git a/block/blk-mq.c b/block/blk-mq.c index d5602ff62c7ce..e0bbe087766f7 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -4362,7 +4362,7 @@ static int blk_mq_alloc_ctxs(struct request_queue *q) struct blk_mq_ctxs *ctxs; int cpu; - ctxs = kzalloc(sizeof(*ctxs), GFP_KERNEL); + ctxs = kzalloc_obj(*ctxs, GFP_KERNEL); if (!ctxs) return -ENOMEM; @@ -4879,7 +4879,7 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set) set->nr_hw_queues = nr_cpu_ids; if (set->flags & BLK_MQ_F_BLOCKING) { - set->srcu = kmalloc(sizeof(*set->srcu), GFP_KERNEL); + set->srcu = kmalloc_obj(*set->srcu, GFP_KERNEL); if (!set->srcu) return -ENOMEM; ret = init_srcu_struct(set->srcu); diff --git a/block/blk-stat.c b/block/blk-stat.c index 682a8ddb11734..2eaa5e27cdb86 100644 --- a/block/blk-stat.c +++ b/block/blk-stat.c @@ -103,12 +103,11 @@ blk_stat_alloc_callback(void (*timer_fn)(struct blk_stat_callback *), { struct blk_stat_callback *cb; - cb = kmalloc(sizeof(*cb), GFP_KERNEL); + cb = kmalloc_obj(*cb, GFP_KERNEL); if (!cb) return NULL; - cb->stat = kmalloc_array(buckets, sizeof(struct blk_rq_stat), - GFP_KERNEL); + cb->stat = kmalloc_objs(struct blk_rq_stat, buckets, GFP_KERNEL); if (!cb->stat) { kfree(cb); return NULL; @@ -207,7 +206,7 @@ struct blk_queue_stats *blk_alloc_queue_stats(void) { struct blk_queue_stats *stats; - stats = kmalloc(sizeof(*stats), GFP_KERNEL); + stats = kmalloc_obj(*stats, GFP_KERNEL); if (!stats) return NULL; diff --git a/block/blk-wbt.c b/block/blk-wbt.c index 6dba71e873871..91115508179be 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -713,7 +713,7 @@ static int wbt_data_dir(const struct request *rq) static struct rq_wb *wbt_alloc(void) { - struct rq_wb *rwb = kzalloc(sizeof(*rwb), GFP_KERNEL); + struct rq_wb *rwb = kzalloc_obj(*rwb, GFP_KERNEL); if (!rwb) return NULL; diff --git a/block/blk-zoned.c b/block/blk-zoned.c index 846b8844f04a9..54ee346ddb5af 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -1804,8 +1804,8 @@ static int disk_alloc_zone_resources(struct gendisk *disk, min(ilog2(pool_size) + 1, BLK_ZONE_WPLUG_MAX_HASH_BITS); disk->zone_wplugs_hash = - kcalloc(disk_zone_wplugs_hash_size(disk), - sizeof(struct hlist_head), GFP_KERNEL); + kzalloc_objs(struct hlist_head, + disk_zone_wplugs_hash_size(disk), GFP_KERNEL); if (!disk->zone_wplugs_hash) return -ENOMEM; diff --git a/block/bsg-lib.c b/block/bsg-lib.c index 9ceb5d0832f58..ca08c6b7fb9cc 100644 --- a/block/bsg-lib.c +++ b/block/bsg-lib.c @@ -368,7 +368,7 @@ struct request_queue *bsg_setup_queue(struct device *dev, const char *name, struct request_queue *q; int ret = -ENOMEM; - bset = kzalloc(sizeof(*bset), GFP_KERNEL); + bset = kzalloc_obj(*bset, GFP_KERNEL); if (!bset) return ERR_PTR(-ENOMEM); diff --git a/block/bsg.c b/block/bsg.c index 72157a59b7881..5f87ea8d5f64b 100644 --- a/block/bsg.c +++ b/block/bsg.c @@ -192,7 +192,7 @@ struct bsg_device *bsg_register_queue(struct request_queue *q, struct bsg_device *bd; int ret; - bd = kzalloc(sizeof(*bd), GFP_KERNEL); + bd = kzalloc_obj(*bd, GFP_KERNEL); if (!bd) return ERR_PTR(-ENOMEM); bd->max_queue = BSG_DEFAULT_CMDS; diff --git a/block/disk-events.c b/block/disk-events.c index 2f697224386aa..04d44d05ed53e 100644 --- a/block/disk-events.c +++ b/block/disk-events.c @@ -436,7 +436,7 @@ int disk_alloc_events(struct gendisk *disk) if (!disk->fops->check_events || !disk->events) return 0; - ev = kzalloc(sizeof(*ev), GFP_KERNEL); + ev = kzalloc_obj(*ev, GFP_KERNEL); if (!ev) { pr_warn("%s: failed to initialize events\n", disk->disk_name); return -ENOMEM; diff --git a/block/fops.c b/block/fops.c index 4d32785b31d90..57a53e0d10160 100644 --- a/block/fops.c +++ b/block/fops.c @@ -65,8 +65,7 @@ static ssize_t __blkdev_direct_IO_simple(struct kiocb *iocb, if (nr_pages <= DIO_INLINE_BIO_VECS) vecs = inline_vecs; else { - vecs = kmalloc_array(nr_pages, sizeof(struct bio_vec), - GFP_KERNEL); + vecs = kmalloc_objs(struct bio_vec, nr_pages, GFP_KERNEL); if (!vecs) return -ENOMEM; } diff --git a/block/genhd.c b/block/genhd.c index 69c75117ba2c0..15866ccf5c33b 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -264,7 +264,7 @@ int __register_blkdev(unsigned int major, const char *name, goto out; } - p = kmalloc(sizeof(struct blk_major_name), GFP_KERNEL); + p = kmalloc_obj(struct blk_major_name, GFP_KERNEL); if (p == NULL) { ret = -ENOMEM; goto out; @@ -914,7 +914,7 @@ static void *disk_seqf_start(struct seq_file *seqf, loff_t *pos) struct class_dev_iter *iter; struct device *dev; - iter = kmalloc(sizeof(*iter), GFP_KERNEL); + iter = kmalloc_obj(*iter, GFP_KERNEL); if (!iter) return ERR_PTR(-ENOMEM); diff --git a/block/holder.c b/block/holder.c index 791091a7eac23..1e7b888153234 100644 --- a/block/holder.c +++ b/block/holder.c @@ -92,7 +92,7 @@ int bd_link_disk_holder(struct block_device *bdev, struct gendisk *disk) goto out_unlock; } - holder = kzalloc(sizeof(*holder), GFP_KERNEL); + holder = kzalloc_obj(*holder, GFP_KERNEL); if (!holder) { ret = -ENOMEM; goto out_unlock; diff --git a/block/partitions/aix.c b/block/partitions/aix.c index 85f4b967565e3..97c8fa2a866fc 100644 --- a/block/partitions/aix.c +++ b/block/partitions/aix.c @@ -199,7 +199,7 @@ int aix_partition(struct parsed_partitions *state) numlvs = be16_to_cpu(p->numlvs); put_dev_sector(sect); } - lvip = kcalloc(state->limit, sizeof(struct lv_info), GFP_KERNEL); + lvip = kzalloc_objs(struct lv_info, state->limit, GFP_KERNEL); if (!lvip) return 0; if (numlvs && (d = read_part_sector(state, vgda_sector + 1, §))) { diff --git a/block/partitions/cmdline.c b/block/partitions/cmdline.c index da3e719d8e51e..5d604a64842e4 100644 --- a/block/partitions/cmdline.c +++ b/block/partitions/cmdline.c @@ -46,7 +46,7 @@ static int parse_subpart(struct cmdline_subpart **subpart, char *partdef) *subpart = NULL; - new_subpart = kzalloc(sizeof(struct cmdline_subpart), GFP_KERNEL); + new_subpart = kzalloc_obj(struct cmdline_subpart, GFP_KERNEL); if (!new_subpart) return -ENOMEM; @@ -122,7 +122,7 @@ static int parse_parts(struct cmdline_parts **parts, char *bdevdef) *parts = NULL; - newparts = kzalloc(sizeof(struct cmdline_parts), GFP_KERNEL); + newparts = kzalloc_obj(struct cmdline_parts, GFP_KERNEL); if (!newparts) return -ENOMEM; diff --git a/block/partitions/core.c b/block/partitions/core.c index 079057ab535a6..189ab56503510 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -94,7 +94,7 @@ static struct parsed_partitions *allocate_partitions(struct gendisk *hd) struct parsed_partitions *state; int nr = DISK_MAX_PARTS; - state = kzalloc(sizeof(*state), GFP_KERNEL); + state = kzalloc_obj(*state, GFP_KERNEL); if (!state) return NULL; diff --git a/block/partitions/efi.c b/block/partitions/efi.c index 638261e9f2fbe..ff145c6306e0b 100644 --- a/block/partitions/efi.c +++ b/block/partitions/efi.c @@ -595,7 +595,7 @@ static int find_valid_gpt(struct parsed_partitions *state, gpt_header **gpt, lastlba = last_lba(state->disk); if (!force_gpt) { /* This will be added to the EFI Spec. per Intel after v1.02. */ - legacymbr = kzalloc(sizeof(*legacymbr), GFP_KERNEL); + legacymbr = kzalloc_obj(*legacymbr, GFP_KERNEL); if (!legacymbr) goto fail; diff --git a/block/partitions/ibm.c b/block/partitions/ibm.c index 631291fbb356b..b81b7a690787d 100644 --- a/block/partitions/ibm.c +++ b/block/partitions/ibm.c @@ -347,13 +347,13 @@ int ibm_partition(struct parsed_partitions *state) nr_sectors = bdev_nr_sectors(bdev); if (nr_sectors == 0) goto out_symbol; - info = kmalloc(sizeof(dasd_information2_t), GFP_KERNEL); + info = kmalloc_obj(dasd_information2_t, GFP_KERNEL); if (info == NULL) goto out_symbol; - geo = kmalloc(sizeof(struct hd_geometry), GFP_KERNEL); + geo = kmalloc_obj(struct hd_geometry, GFP_KERNEL); if (geo == NULL) goto out_nogeo; - label = kmalloc(sizeof(union label_t), GFP_KERNEL); + label = kmalloc_obj(union label_t, GFP_KERNEL); if (label == NULL) goto out_nolab; /* set start if not filled by getgeo function e.g. virtblk */ diff --git a/block/partitions/ldm.c b/block/partitions/ldm.c index 2bd42fedb907a..27ffddd74e119 100644 --- a/block/partitions/ldm.c +++ b/block/partitions/ldm.c @@ -273,8 +273,8 @@ static bool ldm_validate_privheads(struct parsed_partitions *state, BUG_ON (!state || !ph1); - ph[1] = kmalloc (sizeof (*ph[1]), GFP_KERNEL); - ph[2] = kmalloc (sizeof (*ph[2]), GFP_KERNEL); + ph[1] = kmalloc_obj(*ph[1], GFP_KERNEL); + ph[2] = kmalloc_obj(*ph[2], GFP_KERNEL); if (!ph[1] || !ph[2]) { ldm_crit ("Out of memory."); goto out; @@ -362,7 +362,7 @@ static bool ldm_validate_tocblocks(struct parsed_partitions *state, BUG_ON(!state || !ldb); ph = &ldb->ph; tb[0] = &ldb->toc; - tb[1] = kmalloc_array(3, sizeof(*tb[1]), GFP_KERNEL); + tb[1] = kmalloc_objs(*tb[1], 3, GFP_KERNEL); if (!tb[1]) { ldm_crit("Out of memory."); goto err; @@ -1158,7 +1158,7 @@ static bool ldm_ldmdb_add (u8 *data, int len, struct ldmdb *ldb) BUG_ON (!data || !ldb); - vb = kmalloc (sizeof (*vb), GFP_KERNEL); + vb = kmalloc_obj(*vb, GFP_KERNEL); if (!vb) { ldm_crit ("Out of memory."); return false; @@ -1438,7 +1438,7 @@ int ldm_partition(struct parsed_partitions *state) if (!ldm_validate_partition_table(state)) return 0; - ldb = kmalloc (sizeof (*ldb), GFP_KERNEL); + ldb = kmalloc_obj(*ldb, GFP_KERNEL); if (!ldb) { ldm_crit ("Out of memory."); goto out; diff --git a/block/sed-opal.c b/block/sed-opal.c index 23a19c92d7912..fbe0fe4dce8ac 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c @@ -2512,7 +2512,7 @@ struct opal_dev *init_opal_dev(void *data, sec_send_recv *send_recv) { struct opal_dev *dev; - dev = kmalloc(sizeof(*dev), GFP_KERNEL); + dev = kmalloc_obj(*dev, GFP_KERNEL); if (!dev) return NULL; @@ -2719,7 +2719,7 @@ static int opal_save(struct opal_dev *dev, struct opal_lock_unlock *lk_unlk) { struct opal_suspend_data *suspend; - suspend = kzalloc(sizeof(*suspend), GFP_KERNEL); + suspend = kzalloc_obj(*suspend, GFP_KERNEL); if (!suspend) return -ENOMEM; |
