summaryrefslogtreecommitdiff
path: root/drivers/nvme
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2026-02-20 23:49:23 -0800
committerKees Cook <kees@kernel.org>2026-02-21 01:02:28 -0800
commit69050f8d6d075dc01af7a5f2f550a8067510366f (patch)
treebb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/nvme
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
downloadlinux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz
linux-next-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 'drivers/nvme')
-rw-r--r--drivers/nvme/host/auth.c4
-rw-r--r--drivers/nvme/host/core.c22
-rw-r--r--drivers/nvme/host/fabrics.c6
-rw-r--r--drivers/nvme/host/fc.c12
-rw-r--r--drivers/nvme/host/hwmon.c4
-rw-r--r--drivers/nvme/host/pci.c2
-rw-r--r--drivers/nvme/host/rdma.c12
-rw-r--r--drivers/nvme/host/tcp.c10
-rw-r--r--drivers/nvme/host/zns.c4
-rw-r--r--drivers/nvme/target/admin-cmd.c23
-rw-r--r--drivers/nvme/target/configfs.c16
-rw-r--r--drivers/nvme/target/core.c17
-rw-r--r--drivers/nvme/target/discovery.c2
-rw-r--r--drivers/nvme/target/fabrics-cmd.c4
-rw-r--r--drivers/nvme/target/fc.c14
-rw-r--r--drivers/nvme/target/fcloop.c12
-rw-r--r--drivers/nvme/target/io-cmd-file.c3
-rw-r--r--drivers/nvme/target/loop.c6
-rw-r--r--drivers/nvme/target/passthru.c4
-rw-r--r--drivers/nvme/target/pci-epf.c13
-rw-r--r--drivers/nvme/target/pr.c12
-rw-r--r--drivers/nvme/target/rdma.c21
-rw-r--r--drivers/nvme/target/tcp.c9
-rw-r--r--drivers/nvme/target/zns.c4
24 files changed, 115 insertions, 121 deletions
diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c
index 8f3ccb317e4d..20a7347fa258 100644
--- a/drivers/nvme/host/auth.c
+++ b/drivers/nvme/host/auth.c
@@ -1083,8 +1083,8 @@ int nvme_auth_init_ctrl(struct nvme_ctrl *ctrl)
if (!ctrl->opts->dhchap_secret && !ctrl->opts->dhchap_ctrl_secret)
return 0;
- ctrl->dhchap_ctxs = kvcalloc(ctrl_max_dhchaps(ctrl),
- sizeof(*chap), GFP_KERNEL);
+ ctrl->dhchap_ctxs = kvzalloc_objs(*chap, ctrl_max_dhchaps(ctrl),
+ GFP_KERNEL);
if (!ctrl->dhchap_ctxs) {
ret = -ENOMEM;
goto err_free_dhchap_ctrl_secret;
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 19b67cf5d550..fe05fb76afe6 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1469,7 +1469,7 @@ static int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id)
c.identify.opcode = nvme_admin_identify;
c.identify.cns = NVME_ID_CNS_CTRL;
- *id = kmalloc(sizeof(struct nvme_id_ctrl), GFP_KERNEL);
+ *id = kmalloc_obj(struct nvme_id_ctrl, GFP_KERNEL);
if (!*id)
return -ENOMEM;
@@ -1599,7 +1599,7 @@ int nvme_identify_ns(struct nvme_ctrl *ctrl, unsigned nsid,
c.identify.nsid = cpu_to_le32(nsid);
c.identify.cns = NVME_ID_CNS_NS;
- *id = kmalloc(sizeof(**id), GFP_KERNEL);
+ *id = kmalloc_obj(**id, GFP_KERNEL);
if (!*id)
return -ENOMEM;
@@ -1663,7 +1663,7 @@ static int nvme_ns_info_from_id_cs_indep(struct nvme_ctrl *ctrl,
};
int ret;
- id = kmalloc(sizeof(*id), GFP_KERNEL);
+ id = kmalloc_obj(*id, GFP_KERNEL);
if (!id)
return -ENOMEM;
@@ -1923,7 +1923,7 @@ static int nvme_identify_ns_nvm(struct nvme_ctrl *ctrl, unsigned int nsid,
struct nvme_id_ns_nvm *nvm;
int ret;
- nvm = kzalloc(sizeof(*nvm), GFP_KERNEL);
+ nvm = kzalloc_obj(*nvm, GFP_KERNEL);
if (!nvm)
return -ENOMEM;
@@ -2784,7 +2784,7 @@ static int nvme_configure_host_options(struct nvme_ctrl *ctrl)
if (!acre && !lbafee)
return 0;
- host = kzalloc(sizeof(*host), GFP_KERNEL);
+ host = kzalloc_obj(*host, GFP_KERNEL);
if (!host)
return 0;
@@ -2873,7 +2873,7 @@ static int nvme_configure_apst(struct nvme_ctrl *ctrl)
return 0;
}
- table = kzalloc(sizeof(*table), GFP_KERNEL);
+ table = kzalloc_obj(*table, GFP_KERNEL);
if (!table)
return 0;
@@ -3208,7 +3208,7 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
struct nvme_subsystem *subsys, *found;
int ret;
- subsys = kzalloc(sizeof(*subsys), GFP_KERNEL);
+ subsys = kzalloc_obj(*subsys, GFP_KERNEL);
if (!subsys)
return -ENOMEM;
@@ -3326,7 +3326,7 @@ static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi,
if (cel)
goto out;
- cel = kzalloc(sizeof(*cel), GFP_KERNEL);
+ cel = kzalloc_obj(*cel, GFP_KERNEL);
if (!cel)
return -ENOMEM;
@@ -3379,7 +3379,7 @@ static int nvme_init_non_mdts_limits(struct nvme_ctrl *ctrl)
test_bit(NVME_CTRL_SKIP_ID_CNS_CS, &ctrl->flags))
return 0;
- id = kzalloc(sizeof(*id), GFP_KERNEL);
+ id = kzalloc_obj(*id, GFP_KERNEL);
if (!id)
return -ENOMEM;
@@ -3408,7 +3408,7 @@ static int nvme_init_effects_log(struct nvme_ctrl *ctrl,
{
struct nvme_effects_log *effects, *old;
- effects = kzalloc(sizeof(*effects), GFP_KERNEL);
+ effects = kzalloc_obj(*effects, GFP_KERNEL);
if (!effects)
return -ENOMEM;
@@ -4688,7 +4688,7 @@ static void nvme_get_fw_slot_info(struct nvme_ctrl *ctrl)
struct nvme_fw_slot_info_log *log;
u8 next_fw_slot, cur_fw_slot;
- log = kmalloc(sizeof(*log), GFP_KERNEL);
+ log = kmalloc_obj(*log, GFP_KERNEL);
if (!log)
return;
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index 55a8afd2efd5..b4e4bdea1db0 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -26,7 +26,7 @@ static struct nvmf_host *nvmf_host_alloc(const char *hostnqn, uuid_t *id)
{
struct nvmf_host *host;
- host = kmalloc(sizeof(*host), GFP_KERNEL);
+ host = kmalloc_obj(*host, GFP_KERNEL);
if (!host)
return NULL;
@@ -396,7 +396,7 @@ static struct nvmf_connect_data *nvmf_connect_data_prep(struct nvme_ctrl *ctrl,
{
struct nvmf_connect_data *data;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data, GFP_KERNEL);
if (!data)
return NULL;
@@ -1312,7 +1312,7 @@ nvmf_create_ctrl(struct device *dev, const char *buf)
struct nvme_ctrl *ctrl;
int ret;
- opts = kzalloc(sizeof(*opts), GFP_KERNEL);
+ opts = kzalloc_obj(*opts, GFP_KERNEL);
if (!opts)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 6948de3f438a..0b65d1bab4c1 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -1724,15 +1724,15 @@ nvme_fc_rcv_ls_req(struct nvme_fc_remote_port *portptr,
goto out_put;
}
- lsop = kzalloc(sizeof(*lsop), GFP_KERNEL);
+ lsop = kzalloc_obj(*lsop, GFP_KERNEL);
if (!lsop) {
nvme_fc_rcv_ls_req_err_msg(lport, w0);
ret = -ENOMEM;
goto out_put;
}
- lsop->rqstbuf = kzalloc(sizeof(*lsop->rqstbuf), GFP_KERNEL);
- lsop->rspbuf = kzalloc(sizeof(*lsop->rspbuf), GFP_KERNEL);
+ lsop->rqstbuf = kzalloc_obj(*lsop->rqstbuf, GFP_KERNEL);
+ lsop->rspbuf = kzalloc_obj(*lsop->rspbuf, GFP_KERNEL);
if (!lsop->rqstbuf || !lsop->rspbuf) {
nvme_fc_rcv_ls_req_err_msg(lport, w0);
ret = -ENOMEM;
@@ -3443,7 +3443,7 @@ nvme_fc_alloc_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
goto out_fail;
}
- ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
+ ctrl = kzalloc_obj(*ctrl, GFP_KERNEL);
if (!ctrl) {
ret = -ENOMEM;
goto out_fail;
@@ -3497,8 +3497,8 @@ nvme_fc_alloc_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
ctrl->ctrl.cntlid = 0xffff;
ret = -ENOMEM;
- ctrl->queues = kcalloc(ctrl->ctrl.queue_count,
- sizeof(struct nvme_fc_queue), GFP_KERNEL);
+ ctrl->queues = kzalloc_objs(struct nvme_fc_queue,
+ ctrl->ctrl.queue_count, GFP_KERNEL);
if (!ctrl->queues)
goto out_free_ida;
diff --git a/drivers/nvme/host/hwmon.c b/drivers/nvme/host/hwmon.c
index 89a1a1043d63..c60bd960f03a 100644
--- a/drivers/nvme/host/hwmon.c
+++ b/drivers/nvme/host/hwmon.c
@@ -230,11 +230,11 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl)
struct device *hwmon;
int err;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data, GFP_KERNEL);
if (!data)
return -ENOMEM;
- data->log = kzalloc(sizeof(*data->log), GFP_KERNEL);
+ data->log = kzalloc_obj(*data->log, GFP_KERNEL);
if (!data->log) {
err = -ENOMEM;
goto err_free_data;
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 80df992d1ae8..89b5095d1b2e 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2447,7 +2447,7 @@ static int nvme_alloc_host_mem_multi(struct nvme_dev *dev, u64 preferred,
if (!descs)
goto out;
- bufs = kcalloc(max_entries, sizeof(*bufs), GFP_KERNEL);
+ bufs = kzalloc_objs(*bufs, max_entries, GFP_KERNEL);
if (!bufs)
goto out_free_descs;
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 35c0822edb2d..718bbc9b87c1 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -215,7 +215,7 @@ static struct nvme_rdma_qe *nvme_rdma_alloc_ring(struct ib_device *ibdev,
struct nvme_rdma_qe *ring;
int i;
- ring = kcalloc(ib_queue_size, sizeof(struct nvme_rdma_qe), GFP_KERNEL);
+ ring = kzalloc_objs(struct nvme_rdma_qe, ib_queue_size, GFP_KERNEL);
if (!ring)
return NULL;
@@ -300,7 +300,7 @@ static int nvme_rdma_init_request(struct blk_mq_tag_set *set,
struct nvme_rdma_queue *queue = &ctrl->queues[queue_idx];
nvme_req(rq)->ctrl = &ctrl->ctrl;
- req->sqe.data = kzalloc(sizeof(struct nvme_command), GFP_KERNEL);
+ req->sqe.data = kzalloc_obj(struct nvme_command, GFP_KERNEL);
if (!req->sqe.data)
return -ENOMEM;
@@ -375,7 +375,7 @@ nvme_rdma_find_get_device(struct rdma_cm_id *cm_id)
goto out_unlock;
}
- ndev = kzalloc(sizeof(*ndev), GFP_KERNEL);
+ ndev = kzalloc_obj(*ndev, GFP_KERNEL);
if (!ndev)
goto out_err;
@@ -2240,7 +2240,7 @@ static struct nvme_rdma_ctrl *nvme_rdma_alloc_ctrl(struct device *dev,
struct nvme_rdma_ctrl *ctrl;
int ret;
- ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
+ ctrl = kzalloc_obj(*ctrl, GFP_KERNEL);
if (!ctrl)
return ERR_PTR(-ENOMEM);
ctrl->ctrl.opts = opts;
@@ -2290,8 +2290,8 @@ static struct nvme_rdma_ctrl *nvme_rdma_alloc_ctrl(struct device *dev,
ctrl->ctrl.kato = opts->kato;
ret = -ENOMEM;
- ctrl->queues = kcalloc(ctrl->ctrl.queue_count, sizeof(*ctrl->queues),
- GFP_KERNEL);
+ ctrl->queues = kzalloc_objs(*ctrl->queues, ctrl->ctrl.queue_count,
+ GFP_KERNEL);
if (!ctrl->queues)
goto out_free_ctrl;
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 69cb04406b47..489102bdd057 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1467,11 +1467,11 @@ static int nvme_tcp_init_connection(struct nvme_tcp_queue *queue)
u32 maxh2cdata;
int ret;
- icreq = kzalloc(sizeof(*icreq), GFP_KERNEL);
+ icreq = kzalloc_obj(*icreq, GFP_KERNEL);
if (!icreq)
return -ENOMEM;
- icresp = kzalloc(sizeof(*icresp), GFP_KERNEL);
+ icresp = kzalloc_obj(*icresp, GFP_KERNEL);
if (!icresp) {
ret = -ENOMEM;
goto free_icreq;
@@ -2891,7 +2891,7 @@ static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(struct device *dev,
struct nvme_tcp_ctrl *ctrl;
int ret;
- ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
+ ctrl = kzalloc_obj(*ctrl, GFP_KERNEL);
if (!ctrl)
return ERR_PTR(-ENOMEM);
@@ -2949,8 +2949,8 @@ static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(struct device *dev,
goto out_free_ctrl;
}
- ctrl->queues = kcalloc(ctrl->ctrl.queue_count, sizeof(*ctrl->queues),
- GFP_KERNEL);
+ ctrl->queues = kzalloc_objs(*ctrl->queues, ctrl->ctrl.queue_count,
+ GFP_KERNEL);
if (!ctrl->queues) {
ret = -ENOMEM;
goto out_free_ctrl;
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index deea2dbef5b8..68dbe78c90c4 100644
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -13,7 +13,7 @@ static int nvme_set_max_append(struct nvme_ctrl *ctrl)
struct nvme_id_ctrl_zns *id;
int status;
- id = kzalloc(sizeof(*id), GFP_KERNEL);
+ id = kzalloc_obj(*id, GFP_KERNEL);
if (!id)
return -ENOMEM;
@@ -64,7 +64,7 @@ int nvme_query_zone_info(struct nvme_ns *ns, unsigned lbaf,
return status;
}
- id = kzalloc(sizeof(*id), GFP_KERNEL);
+ id = kzalloc_obj(*id, GFP_KERNEL);
if (!id)
return -ENOMEM;
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 5e366502fb75..431702ff21fb 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -203,7 +203,7 @@ static void nvmet_execute_get_supported_log_pages(struct nvmet_req *req)
struct nvme_supported_log *logs;
u16 status;
- logs = kzalloc(sizeof(*logs), GFP_KERNEL);
+ logs = kzalloc_obj(*logs, GFP_KERNEL);
if (!logs) {
status = NVME_SC_INTERNAL;
goto out;
@@ -308,7 +308,7 @@ static void nvmet_execute_get_log_page_rmi(struct nvmet_req *req)
goto out;
}
- log = kzalloc(sizeof(*log), GFP_KERNEL);
+ log = kzalloc_obj(*log, GFP_KERNEL);
if (!log)
goto out;
@@ -334,7 +334,7 @@ static void nvmet_execute_get_log_page_smart(struct nvmet_req *req)
if (req->transfer_len != sizeof(*log))
goto out;
- log = kzalloc(sizeof(*log), GFP_KERNEL);
+ log = kzalloc_obj(*log, GFP_KERNEL);
if (!log)
goto out;
@@ -409,7 +409,7 @@ static void nvmet_execute_get_log_cmd_effects_ns(struct nvmet_req *req)
struct nvme_effects_log *log;
u16 status = NVME_SC_SUCCESS;
- log = kzalloc(sizeof(*log), GFP_KERNEL);
+ log = kzalloc_obj(*log, GFP_KERNEL);
if (!log) {
status = NVME_SC_INTERNAL;
goto out;
@@ -504,7 +504,7 @@ static void nvmet_execute_get_log_page_endgrp(struct nvmet_req *req)
if (status)
goto out;
- log = kzalloc(sizeof(*log), GFP_KERNEL);
+ log = kzalloc_obj(*log, GFP_KERNEL);
if (!log) {
status = NVME_SC_INTERNAL;
goto out;
@@ -542,8 +542,7 @@ static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
u16 status;
status = NVME_SC_INTERNAL;
- desc = kmalloc(struct_size(desc, nsids, NVMET_MAX_NAMESPACES),
- GFP_KERNEL);
+ desc = kmalloc_flex(*desc, nsids, NVMET_MAX_NAMESPACES, GFP_KERNEL);
if (!desc)
goto out;
@@ -581,7 +580,7 @@ static void nvmet_execute_get_log_page_features(struct nvmet_req *req)
struct nvme_supported_features_log *features;
u16 status;
- features = kzalloc(sizeof(*features), GFP_KERNEL);
+ features = kzalloc_obj(*features, GFP_KERNEL);
if (!features) {
status = NVME_SC_INTERNAL;
goto out;
@@ -660,7 +659,7 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
mutex_unlock(&subsys->lock);
}
- id = kzalloc(sizeof(*id), GFP_KERNEL);
+ id = kzalloc_obj(*id, GFP_KERNEL);
if (!id) {
status = NVME_SC_INTERNAL;
goto out;
@@ -809,7 +808,7 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
goto out;
}
- id = kzalloc(sizeof(*id), GFP_KERNEL);
+ id = kzalloc_obj(*id, GFP_KERNEL);
if (!id) {
status = NVME_SC_INTERNAL;
goto out;
@@ -1053,7 +1052,7 @@ static void nvme_execute_identify_ns_nvm(struct nvmet_req *req)
if (status)
goto out;
- id = kzalloc(sizeof(*id), GFP_KERNEL);
+ id = kzalloc_obj(*id, GFP_KERNEL);
if (!id) {
status = NVME_SC_INTERNAL;
goto out;
@@ -1073,7 +1072,7 @@ static void nvmet_execute_id_cs_indep(struct nvmet_req *req)
if (status)
goto out;
- id = kzalloc(sizeof(*id), GFP_KERNEL);
+ id = kzalloc_obj(*id, GFP_KERNEL);
if (!id) {
status = NVME_SC_INTERNAL;
goto out;
diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index 127dae51fec1..6df2844dcec1 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -1040,7 +1040,7 @@ static int nvmet_port_subsys_allow_link(struct config_item *parent,
return -EINVAL;
}
subsys = to_subsys(target);
- link = kmalloc(sizeof(*link), GFP_KERNEL);
+ link = kmalloc_obj(*link, GFP_KERNEL);
if (!link)
return -ENOMEM;
link->subsys = subsys;
@@ -1120,7 +1120,7 @@ static int nvmet_allowed_hosts_allow_link(struct config_item *parent,
}
host = to_host(target);
- link = kmalloc(sizeof(*link), GFP_KERNEL);
+ link = kmalloc_obj(*link, GFP_KERNEL);
if (!link)
return -ENOMEM;
link->host = host;
@@ -1825,7 +1825,7 @@ static struct config_group *nvmet_referral_make(
{
struct nvmet_port *port;
- port = kzalloc(sizeof(*port), GFP_KERNEL);
+ port = kzalloc_obj(*port, GFP_KERNEL);
if (!port)
return ERR_PTR(-ENOMEM);
@@ -1943,7 +1943,7 @@ static struct config_group *nvmet_ana_groups_make_group(
goto out;
ret = -ENOMEM;
- grp = kzalloc(sizeof(*grp), GFP_KERNEL);
+ grp = kzalloc_obj(*grp, GFP_KERNEL);
if (!grp)
goto out;
grp->port = port;
@@ -2022,12 +2022,12 @@ static struct config_group *nvmet_ports_make(struct config_group *group,
if (kstrtou16(name, 0, &portid))
return ERR_PTR(-EINVAL);
- port = kzalloc(sizeof(*port), GFP_KERNEL);
+ port = kzalloc_obj(*port, GFP_KERNEL);
if (!port)
return ERR_PTR(-ENOMEM);
- port->ana_state = kcalloc(NVMET_MAX_ANAGRPS + 1,
- sizeof(*port->ana_state), GFP_KERNEL);
+ port->ana_state = kzalloc_objs(*port->ana_state, NVMET_MAX_ANAGRPS + 1,
+ GFP_KERNEL);
if (!port->ana_state) {
kfree(port);
return ERR_PTR(-ENOMEM);
@@ -2257,7 +2257,7 @@ static struct config_group *nvmet_hosts_make_group(struct config_group *group,
{
struct nvmet_host *host;
- host = kzalloc(sizeof(*host), GFP_KERNEL);
+ host = kzalloc_obj(*host, GFP_KERNEL);
if (!host)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index eab3e4fc0f74..255a6c9b2548 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -194,7 +194,7 @@ void nvmet_add_async_event(struct nvmet_ctrl *ctrl, u8 event_type,
{
struct nvmet_async_event *aen;
- aen = kmalloc(sizeof(*aen), GFP_KERNEL);
+ aen = kmalloc_obj(*aen, GFP_KERNEL);
if (!aen)
return;
@@ -693,7 +693,7 @@ struct nvmet_ns *nvmet_ns_alloc(struct nvmet_subsys *subsys, u32 nsid)
if (subsys->nr_namespaces == NVMET_MAX_NAMESPACES)
goto out_unlock;
- ns = kzalloc(sizeof(*ns), GFP_KERNEL);
+ ns = kzalloc_obj(*ns, GFP_KERNEL);
if (!ns)
goto out_unlock;
@@ -1609,7 +1609,7 @@ struct nvmet_ctrl *nvmet_alloc_ctrl(struct nvmet_alloc_ctrl_args *args)
up_read(&nvmet_config_sem);
args->status = NVME_SC_INTERNAL;
- ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
+ ctrl = kzalloc_obj(*ctrl, GFP_KERNEL);
if (!ctrl)
goto out_put_subsystem;
mutex_init(&ctrl->lock);
@@ -1642,14 +1642,13 @@ struct nvmet_ctrl *nvmet_alloc_ctrl(struct nvmet_alloc_ctrl_args *args)
if (!ctrl->changed_ns_list)
goto out_free_ctrl;
- ctrl->sqs = kcalloc(subsys->max_qid + 1,
- sizeof(struct nvmet_sq *),
- GFP_KERNEL);
+ ctrl->sqs = kzalloc_objs(struct nvmet_sq *, subsys->max_qid + 1,
+ GFP_KERNEL);
if (!ctrl->sqs)
goto out_free_changed_ns_list;
- ctrl->cqs = kcalloc(subsys->max_qid + 1, sizeof(struct nvmet_cq *),
- GFP_KERNEL);
+ ctrl->cqs = kzalloc_objs(struct nvmet_cq *, subsys->max_qid + 1,
+ GFP_KERNEL);
if (!ctrl->cqs)
goto out_free_sqs;
@@ -1829,7 +1828,7 @@ struct nvmet_subsys *nvmet_subsys_alloc(const char *subsysnqn,
char serial[NVMET_SN_MAX_SIZE / 2];
int ret;
- subsys = kzalloc(sizeof(*subsys), GFP_KERNEL);
+ subsys = kzalloc_obj(*subsys, GFP_KERNEL);
if (!subsys)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/nvme/target/discovery.c b/drivers/nvme/target/discovery.c
index c06f3e04296c..8a4a33f82177 100644
--- a/drivers/nvme/target/discovery.c
+++ b/drivers/nvme/target/discovery.c
@@ -263,7 +263,7 @@ static void nvmet_execute_disc_identify(struct nvmet_req *req)
goto out;
}
- id = kzalloc(sizeof(*id), GFP_KERNEL);
+ id = kzalloc_obj(*id, GFP_KERNEL);
if (!id) {
status = NVME_SC_INTERNAL;
goto out;
diff --git a/drivers/nvme/target/fabrics-cmd.c b/drivers/nvme/target/fabrics-cmd.c
index 7b8d8b397802..5c0a1a3dd5b6 100644
--- a/drivers/nvme/target/fabrics-cmd.c
+++ b/drivers/nvme/target/fabrics-cmd.c
@@ -280,7 +280,7 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
if (!nvmet_check_transfer_len(req, sizeof(struct nvmf_connect_data)))
return;
- d = kmalloc(sizeof(*d), GFP_KERNEL);
+ d = kmalloc_obj(*d, GFP_KERNEL);
if (!d) {
args.status = NVME_SC_INTERNAL;
goto complete;
@@ -344,7 +344,7 @@ static void nvmet_execute_io_connect(struct nvmet_req *req)
if (!nvmet_check_transfer_len(req, sizeof(struct nvmf_connect_data)))
return;
- d = kmalloc(sizeof(*d), GFP_KERNEL);
+ d = kmalloc_obj(*d, GFP_KERNEL);
if (!d) {
status = NVME_SC_INTERNAL;
goto complete;
diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
index 0d9784004c9b..69ab0830313d 100644
--- a/drivers/nvme/target/fc.c
+++ b/drivers/nvme/target/fc.c
@@ -528,8 +528,8 @@ nvmet_fc_alloc_ls_iodlist(struct nvmet_fc_tgtport *tgtport)
struct nvmet_fc_ls_iod *iod;
int i;
- iod = kcalloc(NVMET_LS_CTX_COUNT, sizeof(struct nvmet_fc_ls_iod),
- GFP_KERNEL);
+ iod = kzalloc_objs(struct nvmet_fc_ls_iod, NVMET_LS_CTX_COUNT,
+ GFP_KERNEL);
if (!iod)
return -ENOMEM;
@@ -789,7 +789,7 @@ nvmet_fc_alloc_target_queue(struct nvmet_fc_tgt_assoc *assoc,
if (qid > NVMET_NR_QUEUES)
return NULL;
- queue = kzalloc(struct_size(queue, fod, sqsize), GFP_KERNEL);
+ queue = kzalloc_flex(*queue, fod, sqsize, GFP_KERNEL);
if (!queue)
return NULL;
@@ -1034,7 +1034,7 @@ nvmet_fc_alloc_hostport(struct nvmet_fc_tgtport *tgtport, void *hosthandle)
if (match)
return match;
- newhost = kzalloc(sizeof(*newhost), GFP_KERNEL);
+ newhost = kzalloc_obj(*newhost, GFP_KERNEL);
if (!newhost)
return ERR_PTR(-ENOMEM);
@@ -1116,7 +1116,7 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle)
if (!tgtport->pe)
return NULL;
- assoc = kzalloc(sizeof(*assoc), GFP_KERNEL);
+ assoc = kzalloc_obj(*assoc, GFP_KERNEL);
if (!assoc)
return NULL;
@@ -2717,7 +2717,7 @@ nvmet_fc_rcv_fcp_req(struct nvmet_fc_target_port *target_port,
spin_unlock_irqrestore(&queue->qlock, flags);
/* Now we need to dynamically allocate one */
- deferfcp = kmalloc(sizeof(*deferfcp), GFP_KERNEL);
+ deferfcp = kmalloc_obj(*deferfcp, GFP_KERNEL);
if (!deferfcp) {
/* release the queue lookup reference */
nvmet_fc_tgt_q_put(queue);
@@ -2882,7 +2882,7 @@ nvmet_fc_add_port(struct nvmet_port *port)
if (ret)
return ret;
- pe = kzalloc(sizeof(*pe), GFP_KERNEL);
+ pe = kzalloc_obj(*pe, GFP_KERNEL);
if (!pe)
return -ENOMEM;
diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c
index c30e9a3e014f..8473e41e5856 100644
--- a/drivers/nvme/target/fcloop.c
+++ b/drivers/nvme/target/fcloop.c
@@ -559,7 +559,7 @@ fcloop_tgt_discovery_evt(struct nvmet_fc_target_port *tgtport)
{
struct fcloop_rscn *tgt_rscn;
- tgt_rscn = kzalloc(sizeof(*tgt_rscn), GFP_KERNEL);
+ tgt_rscn = kzalloc_obj(*tgt_rscn, GFP_KERNEL);
if (!tgt_rscn)
return;
@@ -766,7 +766,7 @@ fcloop_fcp_req(struct nvme_fc_local_port *localport,
if (!rport->targetport)
return -ECONNREFUSED;
- tfcp_req = kzalloc(sizeof(*tfcp_req), GFP_ATOMIC);
+ tfcp_req = kzalloc_obj(*tfcp_req, GFP_ATOMIC);
if (!tfcp_req)
return -ENOMEM;
@@ -1194,11 +1194,11 @@ fcloop_create_local_port(struct device *dev, struct device_attribute *attr,
unsigned long flags;
int ret = -ENOMEM;
- lport = kzalloc(sizeof(*lport), GFP_KERNEL);
+ lport = kzalloc_obj(*lport, GFP_KERNEL);
if (!lport)
return -ENOMEM;
- opts = kzalloc(sizeof(*opts), GFP_KERNEL);
+ opts = kzalloc_obj(*opts, GFP_KERNEL);
if (!opts)
goto out_free_lport;
@@ -1345,7 +1345,7 @@ fcloop_alloc_nport(const char *buf, size_t count, bool remoteport)
u32 opts_mask = (remoteport) ? RPORT_OPTS : TGTPORT_OPTS;
int ret;
- opts = kzalloc(sizeof(*opts), GFP_KERNEL);
+ opts = kzalloc_obj(*opts, GFP_KERNEL);
if (!opts)
return NULL;
@@ -1357,7 +1357,7 @@ fcloop_alloc_nport(const char *buf, size_t count, bool remoteport)
if ((opts->mask & opts_mask) != opts_mask)
goto out_free_opts;
- newnport = kzalloc(sizeof(*newnport), GFP_KERNEL);
+ newnport = kzalloc_obj(*newnport, GFP_KERNEL);
if (!newnport)
goto out_free_opts;
diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c
index 2d068439b129..6e810a91e6c5 100644
--- a/drivers/nvme/target/io-cmd-file.c
+++ b/drivers/nvme/target/io-cmd-file.c
@@ -228,8 +228,7 @@ static void nvmet_file_execute_rw(struct nvmet_req *req)
}
if (nr_bvec > NVMET_MAX_INLINE_BIOVEC)
- req->f.bvec = kmalloc_array(nr_bvec, sizeof(struct bio_vec),
- GFP_KERNEL);
+ req->f.bvec = kmalloc_objs(struct bio_vec, nr_bvec, GFP_KERNEL);
else
req->f.bvec = req->inline_bvec;
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index fc8e7c9ad858..575c5c31ea29 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -565,7 +565,7 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev,
struct nvme_loop_ctrl *ctrl;
int ret;
- ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
+ ctrl = kzalloc_obj(*ctrl, GFP_KERNEL);
if (!ctrl)
return ERR_PTR(-ENOMEM);
ctrl->ctrl.opts = opts;
@@ -592,8 +592,8 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev,
ctrl->ctrl.kato = opts->kato;
ctrl->port = nvme_loop_find_port(&ctrl->ctrl);
- ctrl->queues = kcalloc(opts->nr_io_queues + 1, sizeof(*ctrl->queues),
- GFP_KERNEL);
+ ctrl->queues = kzalloc_objs(*ctrl->queues, opts->nr_io_queues + 1,
+ GFP_KERNEL);
if (!ctrl->queues)
goto out_uninit_ctrl;
diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c
index 5d541c2a46a5..bac8b8f864ce 100644
--- a/drivers/nvme/target/passthru.c
+++ b/drivers/nvme/target/passthru.c
@@ -86,7 +86,7 @@ static u16 nvmet_passthru_override_id_ctrl(struct nvmet_req *req)
unsigned int max_hw_sectors;
int page_shift;
- id = kzalloc(sizeof(*id), GFP_KERNEL);
+ id = kzalloc_obj(*id, GFP_KERNEL);
if (!id)
return NVME_SC_INTERNAL;
@@ -178,7 +178,7 @@ static u16 nvmet_passthru_override_id_ns(struct nvmet_req *req)
struct nvme_id_ns *id;
int i;
- id = kzalloc(sizeof(*id), GFP_KERNEL);
+ id = kzalloc_obj(*id, GFP_KERNEL);
if (!id)
return NVME_SC_INTERNAL;
diff --git a/drivers/nvme/target/pci-epf.c b/drivers/nvme/target/pci-epf.c
index f858a6c9d7cb..f51a7de9f16a 100644
--- a/drivers/nvme/target/pci-epf.c
+++ b/drivers/nvme/target/pci-epf.c
@@ -502,9 +502,8 @@ static inline int nvmet_pci_epf_transfer(struct nvmet_pci_epf_ctrl *ctrl,
static int nvmet_pci_epf_alloc_irq_vectors(struct nvmet_pci_epf_ctrl *ctrl)
{
- ctrl->irq_vectors = kcalloc(ctrl->nr_queues,
- sizeof(struct nvmet_pci_epf_irq_vector),
- GFP_KERNEL);
+ ctrl->irq_vectors = kzalloc_objs(struct nvmet_pci_epf_irq_vector,
+ ctrl->nr_queues, GFP_KERNEL);
if (!ctrl->irq_vectors)
return -ENOMEM;
@@ -1563,13 +1562,13 @@ static int nvmet_pci_epf_alloc_queues(struct nvmet_pci_epf_ctrl *ctrl)
{
unsigned int qid;
- ctrl->sq = kcalloc(ctrl->nr_queues,
- sizeof(struct nvmet_pci_epf_queue), GFP_KERNEL);
+ ctrl->sq = kzalloc_objs(struct nvmet_pci_epf_queue, ctrl->nr_queues,
+ GFP_KERNEL);
if (!ctrl->sq)
return -ENOMEM;
- ctrl->cq = kcalloc(ctrl->nr_queues,
- sizeof(struct nvmet_pci_epf_queue), GFP_KERNEL);
+ ctrl->cq = kzalloc_objs(struct nvmet_pci_epf_queue, ctrl->nr_queues,
+ GFP_KERNEL);
if (!ctrl->cq) {
kfree(ctrl->sq);
ctrl->sq = NULL;
diff --git a/drivers/nvme/target/pr.c b/drivers/nvme/target/pr.c
index cd22d8333314..254960a844ac 100644
--- a/drivers/nvme/target/pr.c
+++ b/drivers/nvme/target/pr.c
@@ -230,7 +230,7 @@ static u16 nvmet_pr_register(struct nvmet_req *req,
u16 status = NVME_SC_SUCCESS;
u64 nrkey = le64_to_cpu(d->nrkey);
- new = kmalloc(sizeof(*new), GFP_KERNEL);
+ new = kmalloc_obj(*new, GFP_KERNEL);
if (!new)
return NVME_SC_INTERNAL;
@@ -331,7 +331,7 @@ static u16 nvmet_pr_update_reg_attr(struct nvmet_pr *pr,
return NVME_SC_SUCCESS;
}
- new = kmalloc(sizeof(*new), GFP_ATOMIC);
+ new = kmalloc_obj(*new, GFP_ATOMIC);
if (!new)
return NVME_SC_INTERNAL;
@@ -380,7 +380,7 @@ static void nvmet_execute_pr_register(struct nvmet_req *req)
u8 reg_act = cdw10 & 0x07; /* Reservation Register Action, bit 02:00 */
u16 status;
- d = kmalloc(sizeof(*d), GFP_KERNEL);
+ d = kmalloc_obj(*d, GFP_KERNEL);
if (!d) {
status = NVME_SC_INTERNAL;
goto out;
@@ -662,7 +662,7 @@ static void nvmet_execute_pr_acquire(struct nvmet_req *req)
goto out;
}
- d = kmalloc(sizeof(*d), GFP_KERNEL);
+ d = kmalloc_obj(*d, GFP_KERNEL);
if (!d) {
status = NVME_SC_INTERNAL;
goto out;
@@ -773,7 +773,7 @@ static void nvmet_execute_pr_release(struct nvmet_req *req)
goto out;
}
- d = kmalloc(sizeof(*d), GFP_KERNEL);
+ d = kmalloc_obj(*d, GFP_KERNEL);
if (!d) {
status = NVME_SC_INTERNAL;
goto out;
@@ -1013,7 +1013,7 @@ static int nvmet_pr_alloc_and_insert_pc_ref(struct nvmet_ns *ns,
struct nvmet_pr_per_ctrl_ref *pc_ref;
int ret;
- pc_ref = kmalloc(sizeof(*pc_ref), GFP_ATOMIC);
+ pc_ref = kmalloc_obj(*pc_ref, GFP_ATOMIC);
if (!pc_ref)
return -ENOMEM;
diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index 9c12b2361a6d..ae2e27d9cc07 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -222,7 +222,7 @@ nvmet_rdma_get_rsp(struct nvmet_rdma_queue *queue)
if (unlikely(!rsp)) {
int ret;
- rsp = kzalloc(sizeof(*rsp), GFP_KERNEL);
+ rsp = kzalloc_obj(*rsp, GFP_KERNEL);
if (unlikely(!rsp))
return NULL;
ret = nvmet_rdma_alloc_rsp(queue->dev, rsp,
@@ -317,7 +317,7 @@ static int nvmet_rdma_alloc_cmd(struct nvmet_rdma_device *ndev,
struct nvmet_rdma_cmd *c, bool admin)
{
/* NVMe command / RDMA RECV */
- c->nvme_cmd = kmalloc(sizeof(*c->nvme_cmd), GFP_KERNEL);
+ c->nvme_cmd = kmalloc_obj(*c->nvme_cmd, GFP_KERNEL);
if (!c->nvme_cmd)
goto out;
@@ -367,7 +367,7 @@ nvmet_rdma_alloc_cmds(struct nvmet_rdma_device *ndev,
struct nvmet_rdma_cmd *cmds;
int ret = -EINVAL, i;
- cmds = kvcalloc(nr_cmds, sizeof(struct nvmet_rdma_cmd), GFP_KERNEL);
+ cmds = kvzalloc_objs(struct nvmet_rdma_cmd, nr_cmds, GFP_KERNEL);
if (!cmds)
goto out;
@@ -401,7 +401,7 @@ static int nvmet_rdma_alloc_rsp(struct nvmet_rdma_device *ndev,
struct nvmet_rdma_rsp *r, int tag)
{
/* NVMe CQE / RDMA SEND */
- r->req.cqe = kmalloc(sizeof(*r->req.cqe), GFP_KERNEL);
+ r->req.cqe = kmalloc_obj(*r->req.cqe, GFP_KERNEL);
if (!r->req.cqe)
goto out;
@@ -455,8 +455,7 @@ nvmet_rdma_alloc_rsps(struct nvmet_rdma_queue *queue)
NUMA_NO_NODE, false, true))
goto out;
- queue->rsps = kvcalloc(nr_rsps, sizeof(struct nvmet_rdma_rsp),
- GFP_KERNEL);
+ queue->rsps = kvzalloc_objs(struct nvmet_rdma_rsp, nr_rsps, GFP_KERNEL);
if (!queue->rsps)
goto out_free_sbitmap;
@@ -1096,7 +1095,7 @@ nvmet_rdma_init_srq(struct nvmet_rdma_device *ndev)
struct ib_srq *srq;
int ret, i;
- nsrq = kzalloc(sizeof(*nsrq), GFP_KERNEL);
+ nsrq = kzalloc_obj(*nsrq, GFP_KERNEL);
if (!nsrq)
return ERR_PTR(-ENOMEM);
@@ -1155,7 +1154,7 @@ static int nvmet_rdma_init_srqs(struct nvmet_rdma_device *ndev)
ndev->srq_count = min(ndev->device->num_comp_vectors,
ndev->device->attrs.max_srq);
- ndev->srqs = kcalloc(ndev->srq_count, sizeof(*ndev->srqs), GFP_KERNEL);
+ ndev->srqs = kzalloc_objs(*ndev->srqs, ndev->srq_count, GFP_KERNEL);
if (!ndev->srqs)
return -ENOMEM;
@@ -1208,7 +1207,7 @@ nvmet_rdma_find_get_device(struct rdma_cm_id *cm_id)
goto out_unlock;
}
- ndev = kzalloc(sizeof(*ndev), GFP_KERNEL);
+ ndev = kzalloc_obj(*ndev, GFP_KERNEL);
if (!ndev)
goto out_err;
@@ -1430,7 +1429,7 @@ nvmet_rdma_alloc_queue(struct nvmet_rdma_device *ndev,
struct nvmet_rdma_queue *queue;
int ret;
- queue = kzalloc(sizeof(*queue), GFP_KERNEL);
+ queue = kzalloc_obj(*queue, GFP_KERNEL);
if (!queue) {
ret = NVME_RDMA_CM_NO_RSC;
goto out_reject;
@@ -1924,7 +1923,7 @@ static int nvmet_rdma_add_port(struct nvmet_port *nport)
__kernel_sa_family_t af;
int ret;
- port = kzalloc(sizeof(*port), GFP_KERNEL);
+ port = kzalloc_obj(*port, GFP_KERNEL);
if (!port)
return -ENOMEM;
diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index bda816d66846..ac0a44bfa386 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -439,8 +439,7 @@ static int nvmet_tcp_map_data(struct nvmet_tcp_cmd *cmd)
cmd->cur_sg = cmd->req.sg;
if (nvmet_tcp_has_data_in(cmd)) {
- cmd->iov = kmalloc_array(cmd->req.sg_cnt,
- sizeof(*cmd->iov), GFP_KERNEL);
+ cmd->iov = kmalloc_objs(*cmd->iov, cmd->req.sg_cnt, GFP_KERNEL);
if (!cmd->iov)
goto err;
}
@@ -1513,7 +1512,7 @@ static int nvmet_tcp_alloc_cmds(struct nvmet_tcp_queue *queue)
struct nvmet_tcp_cmd *cmds;
int i, ret = -EINVAL, nr_cmds = queue->nr_cmds;
- cmds = kvcalloc(nr_cmds, sizeof(struct nvmet_tcp_cmd), GFP_KERNEL);
+ cmds = kvzalloc_objs(struct nvmet_tcp_cmd, nr_cmds, GFP_KERNEL);
if (!cmds)
goto out;
@@ -1901,7 +1900,7 @@ static void nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port,
struct file *sock_file = NULL;
int ret;
- queue = kzalloc(sizeof(*queue), GFP_KERNEL);
+ queue = kzalloc_obj(*queue, GFP_KERNEL);
if (!queue) {
ret = -ENOMEM;
goto out_release;
@@ -2037,7 +2036,7 @@ static int nvmet_tcp_add_port(struct nvmet_port *nport)
__kernel_sa_family_t af;
int ret;
- port = kzalloc(sizeof(*port), GFP_KERNEL);
+ port = kzalloc_obj(*port, GFP_KERNEL);
if (!port)
return -ENOMEM;
diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
index 15a579cf528c..e895f6b3a308 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -73,7 +73,7 @@ void nvmet_execute_identify_ctrl_zns(struct nvmet_req *req)
struct nvme_id_ctrl_zns *id;
u16 status;
- id = kzalloc(sizeof(*id), GFP_KERNEL);
+ id = kzalloc_obj(*id, GFP_KERNEL);
if (!id) {
status = NVME_SC_INTERNAL;
goto out;
@@ -104,7 +104,7 @@ void nvmet_execute_identify_ns_zns(struct nvmet_req *req)
goto out;
}
- id_zns = kzalloc(sizeof(*id_zns), GFP_KERNEL);
+ id_zns = kzalloc_obj(*id_zns, GFP_KERNEL);
if (!id_zns) {
status = NVME_SC_INTERNAL;
goto out;