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 /drivers/block | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
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 'drivers/block')
34 files changed, 122 insertions, 127 deletions
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c index a9affb7c264d..9897dc9ae678 100644 --- a/drivers/block/aoe/aoecmd.c +++ b/drivers/block/aoe/aoecmd.c @@ -211,7 +211,7 @@ newtframe(struct aoedev *d, struct aoetgt *t) if (list_empty(&t->ffree)) { if (t->falloc >= NSKBPOOLMAX*2) return NULL; - f = kcalloc(1, sizeof(*f), GFP_ATOMIC); + f = kzalloc_objs(*f, 1, GFP_ATOMIC); if (f == NULL) return NULL; t->falloc++; @@ -1431,7 +1431,7 @@ grow_targets(struct aoedev *d) oldn = d->ntargets; newn = oldn * 2; - tt = kcalloc(newn, sizeof(*d->targets), GFP_ATOMIC); + tt = kzalloc_objs(*d->targets, newn, GFP_ATOMIC); if (!tt) return NULL; memmove(tt, d->targets, sizeof(*d->targets) * oldn); @@ -1458,7 +1458,7 @@ addtgt(struct aoedev *d, char *addr, ulong nframes) if (!tt) goto nomem; } - t = kzalloc(sizeof(*t), GFP_ATOMIC); + t = kzalloc_obj(*t, GFP_ATOMIC); if (!t) goto nomem; t->nframes = nframes; @@ -1699,17 +1699,17 @@ aoecmd_init(void) ncpus = num_online_cpus(); - iocq = kcalloc(ncpus, sizeof(struct iocq_ktio), GFP_KERNEL); + iocq = kzalloc_objs(struct iocq_ktio, ncpus, GFP_KERNEL); if (!iocq) return -ENOMEM; - kts = kcalloc(ncpus, sizeof(struct ktstate), GFP_KERNEL); + kts = kzalloc_objs(struct ktstate, ncpus, GFP_KERNEL); if (!kts) { ret = -ENOMEM; goto kts_fail; } - ktiowq = kcalloc(ncpus, sizeof(wait_queue_head_t), GFP_KERNEL); + ktiowq = kzalloc_objs(wait_queue_head_t, ncpus, GFP_KERNEL); if (!ktiowq) { ret = -ENOMEM; goto ktiowq_fail; diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c index 3a240755045b..6e8b3807c1c8 100644 --- a/drivers/block/aoe/aoedev.c +++ b/drivers/block/aoe/aoedev.c @@ -471,10 +471,10 @@ aoedev_by_aoeaddr(ulong maj, int min, int do_alloc) } if (d || !do_alloc || minor_get(&sysminor, maj, min) < 0) goto out; - d = kcalloc(1, sizeof *d, GFP_ATOMIC); + d = kzalloc_objs(*d, 1, GFP_ATOMIC); if (!d) goto out; - d->targets = kcalloc(NTARGETS, sizeof(*d->targets), GFP_ATOMIC); + d->targets = kzalloc_objs(*d->targets, NTARGETS, GFP_ATOMIC); if (!d->targets) { kfree(d); d = NULL; diff --git a/drivers/block/brd.c b/drivers/block/brd.c index a5104cf96609..fe9b3b70f22d 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -272,7 +272,7 @@ static struct brd_device *brd_find_or_alloc_device(int i) } } - brd = kzalloc(sizeof(*brd), GFP_KERNEL); + brd = kzalloc_obj(*brd, GFP_KERNEL); if (!brd) { mutex_unlock(&brd_devices_mutex); return ERR_PTR(-ENOMEM); diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c index d90fa3e7f4cf..2735ddb58b91 100644 --- a/drivers/block/drbd/drbd_bitmap.c +++ b/drivers/block/drbd/drbd_bitmap.c @@ -434,7 +434,7 @@ int drbd_bm_init(struct drbd_device *device) { struct drbd_bitmap *b = device->bitmap; WARN_ON(b != NULL); - b = kzalloc(sizeof(struct drbd_bitmap), GFP_KERNEL); + b = kzalloc_obj(struct drbd_bitmap, GFP_KERNEL); if (!b) return -ENOMEM; spin_lock_init(&b->bm_lock); @@ -1078,7 +1078,7 @@ static int bm_rw(struct drbd_device *device, const unsigned int flags, unsigned * as we submit copies of pages anyways. */ - ctx = kmalloc(sizeof(struct drbd_bm_aio_ctx), GFP_NOIO); + ctx = kmalloc_obj(struct drbd_bm_aio_ctx, GFP_NOIO); if (!ctx) return -ENOMEM; diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 1f6ac9202b66..64c545f5788c 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -2510,7 +2510,7 @@ struct drbd_resource *drbd_create_resource(const char *name) { struct drbd_resource *resource; - resource = kzalloc(sizeof(struct drbd_resource), GFP_KERNEL); + resource = kzalloc_obj(struct drbd_resource, GFP_KERNEL); if (!resource) goto fail; resource->name = kstrdup(name, GFP_KERNEL); @@ -2543,7 +2543,7 @@ struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts) struct drbd_resource *resource; struct drbd_connection *connection; - connection = kzalloc(sizeof(struct drbd_connection), GFP_KERNEL); + connection = kzalloc_obj(struct drbd_connection, GFP_KERNEL); if (!connection) return NULL; @@ -2552,7 +2552,7 @@ struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts) if (drbd_alloc_socket(&connection->meta)) goto fail; - connection->current_epoch = kzalloc(sizeof(struct drbd_epoch), GFP_KERNEL); + connection->current_epoch = kzalloc_obj(struct drbd_epoch, GFP_KERNEL); if (!connection->current_epoch) goto fail; @@ -2666,7 +2666,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig return ERR_MINOR_OR_VOLUME_EXISTS; /* GFP_KERNEL, we are outside of all write-out paths */ - device = kzalloc(sizeof(struct drbd_device), GFP_KERNEL); + device = kzalloc_obj(struct drbd_device, GFP_KERNEL); if (!device) return ERR_NOMEM; kref_init(&device->kref); @@ -2725,7 +2725,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig INIT_LIST_HEAD(&device->peer_devices); INIT_LIST_HEAD(&device->pending_bitmap_io); for_each_connection(connection, resource) { - peer_device = kzalloc(sizeof(struct drbd_peer_device), GFP_KERNEL); + peer_device = kzalloc_obj(struct drbd_peer_device, GFP_KERNEL); if (!peer_device) goto out_idr_remove_from_resource; peer_device->connection = connection; diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index b502038be0a9..fbeb8061e549 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -1536,7 +1536,7 @@ int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info) goto out; } - new_disk_conf = kmalloc(sizeof(struct disk_conf), GFP_KERNEL); + new_disk_conf = kmalloc_obj(struct disk_conf, GFP_KERNEL); if (!new_disk_conf) { retcode = ERR_NOMEM; goto fail; @@ -1785,14 +1785,14 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info) atomic_set(&device->rs_pending_cnt, 0); /* allocation not in the IO path, drbdsetup context */ - nbc = kzalloc(sizeof(struct drbd_backing_dev), GFP_KERNEL); + nbc = kzalloc_obj(struct drbd_backing_dev, GFP_KERNEL); if (!nbc) { retcode = ERR_NOMEM; goto fail; } spin_lock_init(&nbc->md.uuid_lock); - new_disk_conf = kzalloc(sizeof(struct disk_conf), GFP_KERNEL); + new_disk_conf = kzalloc_obj(struct disk_conf, GFP_KERNEL); if (!new_disk_conf) { retcode = ERR_NOMEM; goto fail; @@ -2390,7 +2390,7 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info) connection = adm_ctx.connection; mutex_lock(&adm_ctx.resource->adm_mutex); - new_net_conf = kzalloc(sizeof(struct net_conf), GFP_KERNEL); + new_net_conf = kzalloc_obj(struct net_conf, GFP_KERNEL); if (!new_net_conf) { retcode = ERR_NOMEM; goto out; @@ -2570,7 +2570,7 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info) } /* allocation not in the IO path, drbdsetup / netlink process context */ - new_net_conf = kzalloc(sizeof(*new_net_conf), GFP_KERNEL); + new_net_conf = kzalloc_obj(*new_net_conf, GFP_KERNEL); if (!new_net_conf) { retcode = ERR_NOMEM; goto fail; @@ -2840,7 +2840,7 @@ int drbd_adm_resize(struct sk_buff *skb, struct genl_info *info) u_size = rcu_dereference(device->ldev->disk_conf)->disk_size; rcu_read_unlock(); if (u_size != (sector_t)rs.resize_size) { - new_disk_conf = kmalloc(sizeof(struct disk_conf), GFP_KERNEL); + new_disk_conf = kmalloc_obj(struct disk_conf, GFP_KERNEL); if (!new_disk_conf) { retcode = ERR_NOMEM; goto fail_ldev; diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index 3de919b6f0e1..2545f949ce45 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c @@ -1095,7 +1095,7 @@ static void submit_one_flush(struct drbd_device *device, struct issue_flush_cont { struct bio *bio = bio_alloc(device->ldev->backing_bdev, 0, REQ_OP_WRITE | REQ_PREFLUSH, GFP_NOIO); - struct one_flush_context *octx = kmalloc(sizeof(*octx), GFP_NOIO); + struct one_flush_context *octx = kmalloc_obj(*octx, GFP_NOIO); if (!octx) { drbd_warn(device, "Could not allocate a octx, CANNOT ISSUE FLUSH\n"); @@ -1592,7 +1592,7 @@ static int receive_Barrier(struct drbd_connection *connection, struct packet_inf /* receiver context, in the writeout path of the other node. * avoid potential distributed deadlock */ - epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO); + epoch = kmalloc_obj(struct drbd_epoch, GFP_NOIO); if (epoch) break; else @@ -1605,7 +1605,7 @@ static int receive_Barrier(struct drbd_connection *connection, struct packet_inf drbd_flush(connection); if (atomic_read(&connection->current_epoch->epoch_size)) { - epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO); + epoch = kmalloc_obj(struct drbd_epoch, GFP_NOIO); if (epoch) break; } @@ -3547,7 +3547,7 @@ static int receive_protocol(struct drbd_connection *connection, struct packet_in } } - new_net_conf = kmalloc(sizeof(struct net_conf), GFP_KERNEL); + new_net_conf = kmalloc_obj(struct net_conf, GFP_KERNEL); if (!new_net_conf) goto disconnect; @@ -3708,7 +3708,7 @@ static int receive_SyncParam(struct drbd_connection *connection, struct packet_i mutex_lock(&connection->resource->conf_update); old_net_conf = peer_device->connection->net_conf; if (get_ldev(device)) { - new_disk_conf = kzalloc(sizeof(struct disk_conf), GFP_KERNEL); + new_disk_conf = kzalloc_obj(struct disk_conf, GFP_KERNEL); if (!new_disk_conf) { put_ldev(device); mutex_unlock(&connection->resource->conf_update); @@ -3794,7 +3794,7 @@ static int receive_SyncParam(struct drbd_connection *connection, struct packet_i } if (verify_tfm || csums_tfm) { - new_net_conf = kzalloc(sizeof(struct net_conf), GFP_KERNEL); + new_net_conf = kzalloc_obj(struct net_conf, GFP_KERNEL); if (!new_net_conf) goto disconnect; @@ -3932,7 +3932,8 @@ static int receive_sizes(struct drbd_connection *connection, struct packet_info if (my_usize != p_usize) { struct disk_conf *old_disk_conf, *new_disk_conf = NULL; - new_disk_conf = kzalloc(sizeof(struct disk_conf), GFP_KERNEL); + new_disk_conf = kzalloc_obj(struct disk_conf, + GFP_KERNEL); if (!new_disk_conf) { put_ldev(device); return -ENOMEM; @@ -5692,7 +5693,7 @@ static int got_OVResult(struct drbd_connection *connection, struct packet_info * drbd_advance_rs_marks(peer_device, device->ov_left); if (device->ov_left == 0) { - dw = kmalloc(sizeof(*dw), GFP_NOIO); + dw = kmalloc_obj(*dw, GFP_NOIO); if (dw) { dw->w.cb = w_ov_finished; dw->device = device; diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c index c2b6c4d9729d..adcba7f1d8ea 100644 --- a/drivers/block/drbd/drbd_state.c +++ b/drivers/block/drbd/drbd_state.c @@ -1468,7 +1468,7 @@ _drbd_set_state(struct drbd_device *device, union drbd_state ns, ns.disk > D_NEGOTIATING) device->last_reattach_jif = jiffies; - ascw = kmalloc(sizeof(*ascw), GFP_ATOMIC); + ascw = kmalloc_obj(*ascw, GFP_ATOMIC); if (ascw) { ascw->os = os; ascw->ns = ns; @@ -2351,7 +2351,7 @@ _conn_request_state(struct drbd_connection *connection, union drbd_state mask, u conn_pr_state_change(connection, os, ns_max, flags); remember_new_state(state_change); - acscw = kmalloc(sizeof(*acscw), GFP_ATOMIC); + acscw = kmalloc_obj(*acscw, GFP_ATOMIC); if (acscw) { acscw->oc = os.conn; acscw->ns_min = ns_min; diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c index dea3e79d044f..0697f99fed18 100644 --- a/drivers/block/drbd/drbd_worker.c +++ b/drivers/block/drbd/drbd_worker.c @@ -483,7 +483,7 @@ struct fifo_buffer *fifo_alloc(unsigned int fifo_size) { struct fifo_buffer *fb; - fb = kzalloc(struct_size(fb, values, fifo_size), GFP_NOIO); + fb = kzalloc_flex(*fb, values, fifo_size, GFP_NOIO); if (!fb) return NULL; @@ -871,7 +871,7 @@ int drbd_resync_finished(struct drbd_peer_device *peer_device) * is not finished by now). Retry in 100ms. */ schedule_timeout_interruptible(HZ / 10); - dw = kmalloc(sizeof(struct drbd_device_work), GFP_ATOMIC); + dw = kmalloc_obj(struct drbd_device_work, GFP_ATOMIC); if (dw) { dw->w.cb = w_resync_finished; dw->device = device; diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 98789a5297f2..949bb4adc4bf 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -355,8 +355,7 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, if (rq->bio != rq->biotail) { - bvec = kmalloc_array(nr_bvec, sizeof(struct bio_vec), - GFP_NOIO); + bvec = kmalloc_objs(struct bio_vec, nr_bvec, GFP_NOIO); if (!bvec) return -EIO; cmd->bvec = bvec; @@ -823,7 +822,7 @@ static void loop_queue_work(struct loop_device *lo, struct loop_cmd *cmd) if (worker) goto queue_work; - worker = kzalloc(sizeof(struct loop_worker), GFP_NOWAIT); + worker = kzalloc_obj(struct loop_worker, GFP_NOWAIT); /* * In the event we cannot allocate a worker, just queue on the * rootcg worker and issue the I/O as the rootcg @@ -2010,7 +2009,7 @@ static int loop_add(int i) int err; err = -ENOMEM; - lo = kzalloc(sizeof(*lo), GFP_KERNEL); + lo = kzalloc_obj(*lo, GFP_KERNEL); if (!lo) goto out; lo->worker_tree = RB_ROOT; diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index f6c33b21f69e..d4993d7355dc 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -307,7 +307,7 @@ static void nbd_mark_nsock_dead(struct nbd_device *nbd, struct nbd_sock *nsock, { if (!nsock->dead && notify && !nbd_disconnected(nbd->config)) { struct link_dead_args *args; - args = kmalloc(sizeof(struct link_dead_args), GFP_NOIO); + args = kmalloc_obj(struct link_dead_args, GFP_NOIO); if (args) { INIT_WORK(&args->work, nbd_dead_link_work); args->index = nbd->index; @@ -1274,7 +1274,7 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg, goto put_socket; } - nsock = kzalloc(sizeof(*nsock), GFP_KERNEL); + nsock = kzalloc_obj(*nsock, GFP_KERNEL); if (!nsock) { err = -ENOMEM; goto put_socket; @@ -1322,7 +1322,7 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg) if (!sock) return err; - args = kzalloc(sizeof(*args), GFP_KERNEL); + args = kzalloc_obj(*args, GFP_KERNEL); if (!args) { sockfd_put(sock); return -ENOMEM; @@ -1510,7 +1510,7 @@ retry: for (i = 0; i < num_connections; i++) { struct recv_thread_args *args; - args = kzalloc(sizeof(*args), GFP_KERNEL); + args = kzalloc_obj(*args, GFP_KERNEL); if (!args) { sock_shutdown(nbd); /* @@ -1677,7 +1677,7 @@ static int nbd_alloc_and_init_config(struct nbd_device *nbd) if (!try_module_get(THIS_MODULE)) return -ENODEV; - config = kzalloc(sizeof(struct nbd_config), GFP_NOFS); + config = kzalloc_obj(struct nbd_config, GFP_NOFS); if (!config) { module_put(THIS_MODULE); return -ENOMEM; @@ -1916,7 +1916,7 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs) struct gendisk *disk; int err = -ENOMEM; - nbd = kzalloc(sizeof(struct nbd_device), GFP_KERNEL); + nbd = kzalloc_obj(struct nbd_device, GFP_KERNEL); if (!nbd) goto out; diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 740a8ac42075..6eab18d814e5 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -778,7 +778,7 @@ static struct nullb_device *null_alloc_dev(void) { struct nullb_device *dev; - dev = kzalloc(sizeof(*dev), GFP_KERNEL); + dev = kzalloc_obj(*dev, GFP_KERNEL); if (!dev) return NULL; @@ -867,7 +867,7 @@ static struct nullb_page *null_alloc_page(void) { struct nullb_page *t_page; - t_page = kmalloc(sizeof(struct nullb_page), GFP_NOIO); + t_page = kmalloc_obj(struct nullb_page, GFP_NOIO); if (!t_page) return NULL; @@ -1818,8 +1818,7 @@ static int setup_queues(struct nullb *nullb) if (g_poll_queues) nqueues += g_poll_queues; - nullb->queues = kcalloc(nqueues, sizeof(struct nullb_queue), - GFP_KERNEL); + nullb->queues = kzalloc_objs(struct nullb_queue, nqueues, GFP_KERNEL); if (!nullb->queues) return -ENOMEM; diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c index 0ada35dc0989..384bdce6a9b7 100644 --- a/drivers/block/null_blk/zoned.c +++ b/drivers/block/null_blk/zoned.c @@ -91,8 +91,8 @@ int null_init_zoned_dev(struct nullb_device *dev, dev->nr_zones = round_up(dev_capacity_sects, dev->zone_size_sects) >> ilog2(dev->zone_size_sects); - dev->zones = kvmalloc_array(dev->nr_zones, sizeof(struct nullb_zone), - GFP_KERNEL | __GFP_ZERO); + dev->zones = kvmalloc_objs(struct nullb_zone, dev->nr_zones, + GFP_KERNEL | __GFP_ZERO); if (!dev->zones) return -ENOMEM; diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c index 8892f218a814..4d4b6bcbfa5f 100644 --- a/drivers/block/ps3disk.c +++ b/drivers/block/ps3disk.c @@ -416,7 +416,7 @@ static int ps3disk_probe(struct ps3_system_bus_device *_dev) __set_bit(devidx, &ps3disk_mask); mutex_unlock(&ps3disk_mask_mutex); - priv = kzalloc(sizeof(*priv), GFP_KERNEL); + priv = kzalloc_obj(*priv, GFP_KERNEL); if (!priv) { error = -ENOMEM; goto fail; diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c index bdcf083b45e2..01c743c092be 100644 --- a/drivers/block/ps3vram.c +++ b/drivers/block/ps3vram.c @@ -401,9 +401,8 @@ static int ps3vram_cache_init(struct ps3_system_bus_device *dev) priv->cache.page_count = CACHE_PAGE_COUNT; priv->cache.page_size = CACHE_PAGE_SIZE; - priv->cache.tags = kcalloc(CACHE_PAGE_COUNT, - sizeof(struct ps3vram_tag), - GFP_KERNEL); + priv->cache.tags = kzalloc_objs(struct ps3vram_tag, CACHE_PAGE_COUNT, + GFP_KERNEL); if (!priv->cache.tags) return -ENOMEM; @@ -613,7 +612,7 @@ static int ps3vram_probe(struct ps3_system_bus_device *dev) reports_size, xdr_lpar; char *rest; - priv = kzalloc(sizeof(*priv), GFP_KERNEL); + priv = kzalloc_obj(*priv, GFP_KERNEL); if (!priv) { error = -ENOMEM; goto fail; diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 8f441eb8b192..c9cf07416fa5 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -707,7 +707,7 @@ static struct rbd_client *rbd_client_create(struct ceph_options *ceph_opts) int ret = -ENOMEM; dout("%s:\n", __func__); - rbdc = kmalloc(sizeof(struct rbd_client), GFP_KERNEL); + rbdc = kmalloc_obj(struct rbd_client, GFP_KERNEL); if (!rbdc) goto out_opt; @@ -2572,9 +2572,9 @@ static int rbd_img_fill_request(struct rbd_img_request *img_req, } for_each_obj_request(img_req, obj_req) { - obj_req->bvec_pos.bvecs = kmalloc_array(obj_req->bvec_count, - sizeof(*obj_req->bvec_pos.bvecs), - GFP_NOIO); + obj_req->bvec_pos.bvecs = kmalloc_objs(*obj_req->bvec_pos.bvecs, + obj_req->bvec_count, + GFP_NOIO); if (!obj_req->bvec_pos.bvecs) return -ENOMEM; } @@ -3078,9 +3078,9 @@ static int setup_copyup_bvecs(struct rbd_obj_request *obj_req, u64 obj_overlap) rbd_assert(!obj_req->copyup_bvecs); obj_req->copyup_bvec_count = calc_pages_for(0, obj_overlap); - obj_req->copyup_bvecs = kcalloc(obj_req->copyup_bvec_count, - sizeof(*obj_req->copyup_bvecs), - GFP_NOIO); + obj_req->copyup_bvecs = kzalloc_objs(*obj_req->copyup_bvecs, + obj_req->copyup_bvec_count, + GFP_NOIO); if (!obj_req->copyup_bvecs) return -ENOMEM; @@ -5289,7 +5289,7 @@ static struct rbd_spec *rbd_spec_alloc(void) { struct rbd_spec *spec; - spec = kzalloc(sizeof (*spec), GFP_KERNEL); + spec = kzalloc_obj(*spec, GFP_KERNEL); if (!spec) return NULL; @@ -5352,7 +5352,7 @@ static struct rbd_device *__rbd_dev_create(struct rbd_spec *spec) { struct rbd_device *rbd_dev; - rbd_dev = kzalloc(sizeof(*rbd_dev), GFP_KERNEL); + rbd_dev = kzalloc_obj(*rbd_dev, GFP_KERNEL); if (!rbd_dev) return NULL; @@ -6509,7 +6509,7 @@ static int rbd_add_parse_args(const char *buf, /* Initialize all rbd options to the defaults */ - pctx.opts = kzalloc(sizeof(*pctx.opts), GFP_KERNEL); + pctx.opts = kzalloc_obj(*pctx.opts, GFP_KERNEL); if (!pctx.opts) goto out_mem; diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c index 144aea1466a4..6ca1221693ff 100644 --- a/drivers/block/rnbd/rnbd-clt-sysfs.c +++ b/drivers/block/rnbd/rnbd-clt-sysfs.c @@ -591,7 +591,7 @@ static ssize_t rnbd_clt_map_device_store(struct kobject *kobj, opt.dest_port = &port_nr; opt.access_mode = &access_mode; opt.nr_poll_queues = &nr_poll_queues; - addrs = kcalloc(ARRAY_SIZE(paths) * 2, sizeof(*addrs), GFP_KERNEL); + addrs = kzalloc_objs(*addrs, ARRAY_SIZE(paths) * 2, GFP_KERNEL); if (!addrs) return -ENOMEM; diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index 757df2896aeb..59896090d856 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -324,7 +324,7 @@ static struct rnbd_iu *rnbd_get_iu(struct rnbd_clt_session *sess, struct rnbd_iu *iu; struct rtrs_permit *permit; - iu = kzalloc(sizeof(*iu), GFP_KERNEL); + iu = kzalloc_obj(*iu, GFP_KERNEL); if (!iu) return NULL; @@ -541,7 +541,7 @@ static int send_msg_open(struct rnbd_clt_dev *dev, enum wait_type wait) }; int err, errno; - rsp = kzalloc(sizeof(*rsp), GFP_KERNEL); + rsp = kzalloc_obj(*rsp, GFP_KERNEL); if (!rsp) return -ENOMEM; @@ -587,7 +587,7 @@ static int send_msg_sess_info(struct rnbd_clt_session *sess, enum wait_type wait }; int err, errno; - rsp = kzalloc(sizeof(*rsp), GFP_KERNEL); + rsp = kzalloc_obj(*rsp, GFP_KERNEL); if (!rsp) return -ENOMEM; @@ -1417,9 +1417,8 @@ static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess, * nr_cpu_ids: the number of softirq queues * nr_poll_queues: the number of polling queues */ - dev->hw_queues = kcalloc(nr_cpu_ids + nr_poll_queues, - sizeof(*dev->hw_queues), - GFP_KERNEL); + dev->hw_queues = kzalloc_objs(*dev->hw_queues, + nr_cpu_ids + nr_poll_queues, GFP_KERNEL); if (!dev->hw_queues) { ret = -ENOMEM; goto out_alloc; @@ -1565,7 +1564,7 @@ struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname, goto put_dev; } - rsp = kzalloc(sizeof(*rsp), GFP_KERNEL); + rsp = kzalloc_obj(*rsp, GFP_KERNEL); if (!rsp) { ret = -ENOMEM; goto del_dev; diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c index 7eeb321d6140..d644e59529ca 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -128,7 +128,7 @@ static int process_rdma(struct rnbd_srv_session *srv_sess, trace_process_rdma(srv_sess, msg, id, datalen, usrlen); - priv = kmalloc(sizeof(*priv), GFP_KERNEL); + priv = kmalloc_obj(*priv, GFP_KERNEL); if (!priv) return -ENOMEM; @@ -287,7 +287,7 @@ static int create_sess(struct rtrs_srv_sess *rtrs) return err; } - srv_sess = kzalloc(sizeof(*srv_sess), GFP_KERNEL); + srv_sess = kzalloc_obj(*srv_sess, GFP_KERNEL); if (!srv_sess) return -ENOMEM; @@ -422,7 +422,7 @@ static struct rnbd_srv_sess_dev struct rnbd_srv_sess_dev *sess_dev; int error; - sess_dev = kzalloc(sizeof(*sess_dev), GFP_KERNEL); + sess_dev = kzalloc_obj(*sess_dev, GFP_KERNEL); if (!sess_dev) return ERR_PTR(-ENOMEM); @@ -441,7 +441,7 @@ static struct rnbd_srv_dev *rnbd_srv_init_srv_dev(struct block_device *bdev) { struct rnbd_srv_dev *dev; - dev = kzalloc(sizeof(*dev), GFP_KERNEL); + dev = kzalloc_obj(*dev, GFP_KERNEL); if (!dev) return ERR_PTR(-ENOMEM); diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c index db1fe9772a4d..7cf8f8899892 100644 --- a/drivers/block/sunvdc.c +++ b/drivers/block/sunvdc.c @@ -992,7 +992,7 @@ static int vdc_port_probe(struct vio_dev *vdev, const struct vio_device_id *id) goto err_out_release_mdesc; } - port = kzalloc(sizeof(*port), GFP_KERNEL); + port = kzalloc_obj(*port, GFP_KERNEL); if (!port) { err = -ENOMEM; goto err_out_release_mdesc; diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 416015947ae6..3b015a9c752f 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -896,7 +896,7 @@ static int swim_probe(struct platform_device *dev) /* set platform driver data */ - swd = kzalloc(sizeof(struct swim_priv), GFP_KERNEL); + swd = kzalloc_obj(struct swim_priv, GFP_KERNEL); if (!swd) { ret = -ENOMEM; goto out_release_io; diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index c13cda58a7c6..c47dc9814e36 100644 --- a/drivers/block/ublk_drv.c +++ b/drivers/block/ublk_drv.c @@ -710,7 +710,7 @@ static DEFINE_MUTEX(ublk_ctl_mutex); static struct ublk_batch_fetch_cmd * ublk_batch_alloc_fcmd(struct io_uring_cmd *cmd) { - struct ublk_batch_fetch_cmd *fcmd = kzalloc(sizeof(*fcmd), GFP_NOIO); + struct ublk_batch_fetch_cmd *fcmd = kzalloc_obj(*fcmd, GFP_NOIO); if (fcmd) { fcmd->cmd = cmd; @@ -4610,7 +4610,7 @@ static int ublk_ctrl_add_dev(const struct ublksrv_ctrl_cmd *header) goto out_unlock; ret = -ENOMEM; - ub = kzalloc(struct_size(ub, queues, info.nr_hw_queues), GFP_KERNEL); + ub = kzalloc_flex(*ub, queues, info.nr_hw_queues, GFP_KERNEL); if (!ub) goto out_unlock; mutex_init(&ub->mutex); diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 357434bdae99..1ee1ebe693bf 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -168,7 +168,7 @@ static int virtblk_setup_discard_write_zeroes_erase(struct request *req, bool un if (unmap) flags |= VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP; - range = kmalloc_array(segments, sizeof(*range), GFP_ATOMIC); + range = kmalloc_objs(*range, segments, GFP_ATOMIC); if (!range) return -ENOMEM; @@ -991,12 +991,12 @@ static int init_vq(struct virtio_blk *vblk) vblk->io_queues[HCTX_TYPE_READ], vblk->io_queues[HCTX_TYPE_POLL]); - vblk->vqs = kmalloc_array(num_vqs, sizeof(*vblk->vqs), GFP_KERNEL); + vblk->vqs = kmalloc_objs(*vblk->vqs, num_vqs, GFP_KERNEL); if (!vblk->vqs) return -ENOMEM; - vqs_info = kcalloc(num_vqs, sizeof(*vqs_info), GFP_KERNEL); - vqs = kmalloc_array(num_vqs, sizeof(*vqs), GFP_KERNEL); + vqs_info = kzalloc_objs(*vqs_info, num_vqs, GFP_KERNEL); + vqs = kmalloc_objs(*vqs, num_vqs, GFP_KERNEL); if (!vqs_info || !vqs) { err = -ENOMEM; goto out; @@ -1455,7 +1455,7 @@ static int virtblk_probe(struct virtio_device *vdev) goto out; index = err; - vdev->priv = vblk = kmalloc(sizeof(*vblk), GFP_KERNEL); + vdev->priv = vblk = kmalloc_obj(*vblk, GFP_KERNEL); if (!vblk) { err = -ENOMEM; goto out_free_index; diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c index a7c2b04ab943..bc665b8abd7b 100644 --- a/drivers/block/xen-blkback/blkback.c +++ b/drivers/block/xen-blkback/blkback.c @@ -846,8 +846,8 @@ again: * We are using persistent grants, the grant is * not mapped but we might have room for it. */ - persistent_gnt = kmalloc(sizeof(struct persistent_gnt), - GFP_KERNEL); + persistent_gnt = kmalloc_obj(struct persistent_gnt, + GFP_KERNEL); if (!persistent_gnt) { /* * If we don't have enough memory to diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c index 0621878940ae..448417097837 100644 --- a/drivers/block/xen-blkback/xenbus.c +++ b/drivers/block/xen-blkback/xenbus.c @@ -131,8 +131,8 @@ static int xen_blkif_alloc_rings(struct xen_blkif *blkif) { unsigned int r; - blkif->rings = kcalloc(blkif->nr_rings, sizeof(struct xen_blkif_ring), - GFP_KERNEL); + blkif->rings = kzalloc_objs(struct xen_blkif_ring, blkif->nr_rings, + GFP_KERNEL); if (!blkif->rings) return -ENOMEM; @@ -628,8 +628,7 @@ static int xen_blkbk_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) { int err; - struct backend_info *be = kzalloc(sizeof(struct backend_info), - GFP_KERNEL); + struct backend_info *be = kzalloc_obj(struct backend_info, GFP_KERNEL); /* match the pr_debug in xen_blkbk_remove */ pr_debug("%s %p %d\n", __func__, dev, dev->otherend_id); @@ -1010,18 +1009,19 @@ static int read_per_ring_refs(struct xen_blkif_ring *ring, const char *dir) err = -ENOMEM; for (i = 0; i < nr_grefs * XEN_BLKIF_REQS_PER_PAGE; i++) { - req = kzalloc(sizeof(*req), GFP_KERNEL); + req = kzalloc_obj(*req, GFP_KERNEL); if (!req) goto fail; list_add_tail(&req->free_list, &ring->pending_free); for (j = 0; j < MAX_INDIRECT_SEGMENTS; j++) { - req->segments[j] = kzalloc(sizeof(*req->segments[0]), GFP_KERNEL); + req->segments[j] = kzalloc_obj(*req->segments[0], + GFP_KERNEL); if (!req->segments[j]) goto fail; } for (j = 0; j < MAX_INDIRECT_PAGES; j++) { - req->indirect_pages[j] = kzalloc(sizeof(*req->indirect_pages[0]), - GFP_KERNEL); + req->indirect_pages[j] = kzalloc_obj(*req->indirect_pages[0], + GFP_KERNEL); if (!req->indirect_pages[j]) goto fail; } diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 04fc6b552c04..e8aec3857dd5 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -314,7 +314,7 @@ static int fill_grant_buffer(struct blkfront_ring_info *rinfo, int num) int i = 0; while (i < num) { - gnt_list_entry = kzalloc(sizeof(struct grant), GFP_NOIO); + gnt_list_entry = kzalloc_obj(struct grant, GFP_NOIO); if (!gnt_list_entry) goto out_of_memory; @@ -1980,7 +1980,7 @@ static int blkfront_probe(struct xenbus_device *dev, } kfree(type); } - info = kzalloc(sizeof(*info), GFP_KERNEL); + info = kzalloc_obj(*info, GFP_KERNEL); if (!info) { xenbus_dev_fatal(dev, -ENOMEM, "allocating info structure"); return -ENOMEM; @@ -2207,17 +2207,15 @@ static int blkfront_setup_indirect(struct blkfront_ring_info *rinfo) for (i = 0; i < BLK_RING_SIZE(info); i++) { rinfo->shadow[i].grants_used = - kvcalloc(grants, - sizeof(rinfo->shadow[i].grants_used[0]), - GFP_KERNEL); - rinfo->shadow[i].sg = kvcalloc(psegs, - sizeof(rinfo->shadow[i].sg[0]), - GFP_KERNEL); + kvzalloc_objs(rinfo->shadow[i].grants_used[0], grants, + GFP_KERNEL); + rinfo->shadow[i].sg = kvzalloc_objs(rinfo->shadow[i].sg[0], + psegs, GFP_KERNEL); if (info->max_indirect_segments) rinfo->shadow[i].indirect_grants = - kvcalloc(INDIRECT_GREFS(grants), - sizeof(rinfo->shadow[i].indirect_grants[0]), - GFP_KERNEL); + kvzalloc_objs(rinfo->shadow[i].indirect_grants[0], + INDIRECT_GREFS(grants), + GFP_KERNEL); if ((rinfo->shadow[i].grants_used == NULL) || (rinfo->shadow[i].sg == NULL) || (info->max_indirect_segments && diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c index 8c1c7f4211eb..e12abdec2647 100644 --- a/drivers/block/z2ram.c +++ b/drivers/block/z2ram.c @@ -187,8 +187,8 @@ static int z2_open(struct gendisk *disk, blk_mode_t mode) (unsigned long)z_remap_nocache_nonser(paddr, size); #endif z2ram_map = - kmalloc_array(size / Z2RAM_CHUNKSIZE, - sizeof(z2ram_map[0]), GFP_KERNEL); + kmalloc_objs(z2ram_map[0], size / Z2RAM_CHUNKSIZE, + GFP_KERNEL); if (z2ram_map == NULL) { printk(KERN_ERR DEVICE_NAME ": cannot get mem for z2ram_map\n"); diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c index 8e334f5025fc..9da9855dd6e0 100644 --- a/drivers/block/zloop.c +++ b/drivers/block/zloop.c @@ -492,7 +492,7 @@ static void zloop_rw(struct zloop_cmd *cmd) if (rq->bio != rq->biotail) { struct bio_vec *bvec; - cmd->bvec = kmalloc_array(nr_bvec, sizeof(*cmd->bvec), GFP_NOIO); + cmd->bvec = kmalloc_objs(*cmd->bvec, nr_bvec, GFP_NOIO); if (!cmd->bvec) { ret = -EIO; goto unlock; @@ -997,7 +997,7 @@ static int zloop_ctl_add(struct zloop_options *opts) goto out; } - zlo = kvzalloc(struct_size(zlo, zones, nr_zones), GFP_KERNEL); + zlo = kvzalloc_flex(*zlo, zones, nr_zones, GFP_KERNEL); if (!zlo) { ret = -ENOMEM; goto out; diff --git a/drivers/block/zram/backend_deflate.c b/drivers/block/zram/backend_deflate.c index b75016e0e654..7dee3aacb2d8 100644 --- a/drivers/block/zram/backend_deflate.c +++ b/drivers/block/zram/backend_deflate.c @@ -54,7 +54,7 @@ static int deflate_create(struct zcomp_params *params, struct zcomp_ctx *ctx) size_t sz; int ret; - zctx = kzalloc(sizeof(*zctx), GFP_KERNEL); + zctx = kzalloc_obj(*zctx, GFP_KERNEL); if (!zctx) return -ENOMEM; diff --git a/drivers/block/zram/backend_lz4.c b/drivers/block/zram/backend_lz4.c index daccd60857eb..3416fec9e982 100644 --- a/drivers/block/zram/backend_lz4.c +++ b/drivers/block/zram/backend_lz4.c @@ -41,7 +41,7 @@ static int lz4_create(struct zcomp_params *params, struct zcomp_ctx *ctx) { struct lz4_ctx *zctx; - zctx = kzalloc(sizeof(*zctx), GFP_KERNEL); + zctx = kzalloc_obj(*zctx, GFP_KERNEL); if (!zctx) return -ENOMEM; @@ -51,11 +51,11 @@ static int lz4_create(struct zcomp_params *params, struct zcomp_ctx *ctx) if (!zctx->mem) goto error; } else { - zctx->dstrm = kzalloc(sizeof(*zctx->dstrm), GFP_KERNEL); + zctx->dstrm = kzalloc_obj(*zctx->dstrm, GFP_KERNEL); if (!zctx->dstrm) goto error; - zctx->cstrm = kzalloc(sizeof(*zctx->cstrm), GFP_KERNEL); + zctx->cstrm = kzalloc_obj(*zctx->cstrm, GFP_KERNEL); if (!zctx->cstrm) goto error; } diff --git a/drivers/block/zram/backend_lz4hc.c b/drivers/block/zram/backend_lz4hc.c index 9e8a35dfa56d..fd94df9193d3 100644 --- a/drivers/block/zram/backend_lz4hc.c +++ b/drivers/block/zram/backend_lz4hc.c @@ -41,7 +41,7 @@ static int lz4hc_create(struct zcomp_params *params, struct zcomp_ctx *ctx) { struct lz4hc_ctx *zctx; - zctx = kzalloc(sizeof(*zctx), GFP_KERNEL); + zctx = kzalloc_obj(*zctx, GFP_KERNEL); if (!zctx) return -ENOMEM; @@ -51,11 +51,11 @@ static int lz4hc_create(struct zcomp_params *params, struct zcomp_ctx *ctx) if (!zctx->mem) goto error; } else { - zctx->dstrm = kzalloc(sizeof(*zctx->dstrm), GFP_KERNEL); + zctx->dstrm = kzalloc_obj(*zctx->dstrm, GFP_KERNEL); if (!zctx->dstrm) goto error; - zctx->cstrm = kzalloc(sizeof(*zctx->cstrm), GFP_KERNEL); + zctx->cstrm = kzalloc_obj(*zctx->cstrm, GFP_KERNEL); if (!zctx->cstrm) goto error; } diff --git a/drivers/block/zram/backend_zstd.c b/drivers/block/zram/backend_zstd.c index 81defb98ed09..d9303269b90d 100644 --- a/drivers/block/zram/backend_zstd.c +++ b/drivers/block/zram/backend_zstd.c @@ -53,7 +53,7 @@ static int zstd_setup_params(struct zcomp_params *params) zstd_compression_parameters prm; struct zstd_params *zp; - zp = kzalloc(sizeof(*zp), GFP_KERNEL); + zp = kzalloc_obj(*zp, GFP_KERNEL); if (!zp) return -ENOMEM; @@ -122,7 +122,7 @@ static int zstd_create(struct zcomp_params *params, struct zcomp_ctx *ctx) zstd_parameters prm; size_t sz; - zctx = kzalloc(sizeof(*zctx), GFP_KERNEL); + zctx = kzalloc_obj(*zctx, GFP_KERNEL); if (!zctx) return -ENOMEM; diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c index b1bd1daa0060..b53fb5fbc041 100644 --- a/drivers/block/zram/zcomp.c +++ b/drivers/block/zram/zcomp.c @@ -238,7 +238,7 @@ struct zcomp *zcomp_create(const char *alg, struct zcomp_params *params) */ BUILD_BUG_ON(ARRAY_SIZE(backends) <= 1); - comp = kzalloc(sizeof(struct zcomp), GFP_KERNEL); + comp = kzalloc_obj(struct zcomp, GFP_KERNEL); if (!comp) return ERR_PTR(-ENOMEM); diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 61d3e2c74901..3cc82b88b07e 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -250,7 +250,7 @@ static struct zram_pp_ctl *init_pp_ctl(void) struct zram_pp_ctl *ctl; u32 idx; - ctl = kmalloc(sizeof(*ctl), GFP_KERNEL); + ctl = kmalloc_obj(*ctl, GFP_KERNEL); if (!ctl) return NULL; @@ -297,7 +297,7 @@ static bool place_pp_slot(struct zram *zram, struct zram_pp_ctl *ctl, struct zram_pp_slot *pps; u32 bid; - pps = kmalloc(sizeof(*pps), GFP_NOIO | __GFP_NOWARN); + pps = kmalloc_obj(*pps, GFP_NOIO | __GFP_NOWARN); if (!pps) return false; @@ -855,7 +855,7 @@ static struct zram_wb_ctl *init_wb_ctl(struct zram *zram) struct zram_wb_ctl *wb_ctl; int i; - wb_ctl = kmalloc(sizeof(*wb_ctl), GFP_KERNEL); + wb_ctl = kmalloc_obj(*wb_ctl, GFP_KERNEL); if (!wb_ctl) return NULL; @@ -875,7 +875,7 @@ static struct zram_wb_ctl *init_wb_ctl(struct zram *zram) * writeback can still proceed, even if there is only one * request on the idle list. */ - req = kzalloc(sizeof(*req), GFP_KERNEL | __GFP_NOWARN); + req = kzalloc_obj(*req, GFP_KERNEL | __GFP_NOWARN); if (!req) break; @@ -1452,7 +1452,7 @@ static void read_from_bdev_async(struct zram *zram, struct page *page, struct zram_rb_req *req; struct bio *bio; - req = kmalloc(sizeof(*req), GFP_NOIO); + req = kmalloc_obj(*req, GFP_NOIO); if (!req) return; @@ -3079,7 +3079,7 @@ static int zram_add(void) struct zram *zram; int ret, device_id; - zram = kzalloc(sizeof(struct zram), GFP_KERNEL); + zram = kzalloc_obj(struct zram, GFP_KERNEL); if (!zram) return -ENOMEM; |
