mirror of
https://github.com/SCST-project/scst.git
synced 2026-07-25 01:23:14 +00:00
scst: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Linux kernel Coccinelle script from scripts/coccinelle/api/kmalloc_objs.cocci against the SCST tree. This patch doesn't change any functionality.
This commit is contained in:
+1
-1
@@ -559,7 +559,7 @@ static void ft_recv_cmd(struct ft_sess *sess, struct fc_frame *fp)
|
||||
if (!sp)
|
||||
goto busy;
|
||||
|
||||
fcmd = kzalloc(sizeof(*fcmd), GFP_ATOMIC);
|
||||
fcmd = kzalloc_obj(*fcmd, GFP_ATOMIC);
|
||||
if (!fcmd)
|
||||
goto busy;
|
||||
fcmd->max_payload = sess->max_payload;
|
||||
|
||||
+3
-3
@@ -56,7 +56,7 @@ static struct ft_tport *ft_tport_create(struct fc_lport *lport)
|
||||
return tport;
|
||||
}
|
||||
|
||||
tport = kzalloc(sizeof(*tport), GFP_KERNEL);
|
||||
tport = kzalloc_obj(*tport);
|
||||
if (!tport) {
|
||||
FT_SESS_DBG("tport alloc %s failed\n", name);
|
||||
return NULL;
|
||||
@@ -214,7 +214,7 @@ static int ft_sess_create(struct ft_tport *tport, struct fc_rport_priv *rdata,
|
||||
}
|
||||
}
|
||||
|
||||
sess = kzalloc(sizeof(*sess), GFP_KERNEL);
|
||||
sess = kzalloc_obj(*sess);
|
||||
if (!sess)
|
||||
return FC_SPP_RESP_RES; /* out of resources */
|
||||
|
||||
@@ -316,7 +316,7 @@ int ft_get_transport_id(struct scst_tgt *tgt, struct scst_session *scst_sess, ui
|
||||
if (!scst_sess)
|
||||
return SCSI_TRANSPORTID_PROTOCOLID_FCP2;
|
||||
|
||||
id = kzalloc(sizeof(*id), GFP_KERNEL);
|
||||
id = kzalloc_obj(*id);
|
||||
if (!id)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ static int add_session(void __user *ptr)
|
||||
|
||||
lockdep_assert_held(&target_mgmt_mutex);
|
||||
|
||||
info = kzalloc(sizeof(*info), GFP_KERNEL);
|
||||
info = kzalloc_obj(*info);
|
||||
if (!info) {
|
||||
PRINT_ERROR("Can't alloc info (size %zd)", sizeof(*info));
|
||||
err = -ENOMEM;
|
||||
@@ -227,7 +227,7 @@ static int del_session(void __user *ptr)
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
info = kzalloc(sizeof(*info), GFP_KERNEL);
|
||||
info = kzalloc_obj(*info);
|
||||
if (!info) {
|
||||
PRINT_ERROR("Can't alloc info (size %zd)", sizeof(*info));
|
||||
err = -ENOMEM;
|
||||
@@ -522,7 +522,7 @@ int iscsi_add_attr(struct iscsi_target *target, const struct iscsi_kern_attr *at
|
||||
TRACE_DBG("Adding %s's attr %s with mode %x", name,
|
||||
attr_info->name, attr_info->mode);
|
||||
|
||||
tgt_attr = kzalloc(sizeof(*tgt_attr), GFP_KERNEL);
|
||||
tgt_attr = kzalloc_obj(*tgt_attr);
|
||||
if (!tgt_attr) {
|
||||
PRINT_ERROR("Unable to allocate user (size %zd)",
|
||||
sizeof(*tgt_attr));
|
||||
@@ -699,7 +699,7 @@ static int add_target(void __user *ptr)
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
info = kzalloc(sizeof(*info), GFP_KERNEL);
|
||||
info = kzalloc_obj(*info);
|
||||
if (!info) {
|
||||
PRINT_ERROR("Can't alloc info (size %zd)", sizeof(*info));
|
||||
err = -ENOMEM;
|
||||
|
||||
@@ -4119,7 +4119,7 @@ create:
|
||||
|
||||
for (j = 0; j < 2; j++) {
|
||||
for (i = 0; i < count; i++) {
|
||||
t = kmalloc(sizeof(*t), GFP_KERNEL);
|
||||
t = kmalloc_obj(*t);
|
||||
if (!t) {
|
||||
res = -ENOMEM;
|
||||
PRINT_ERROR("Failed to allocate thread (size %zd)",
|
||||
|
||||
@@ -49,8 +49,7 @@ static int isert_buf_alloc_pg(struct ib_device *ib_dev,
|
||||
struct page *page;
|
||||
|
||||
isert_buf->sg_cnt = DIV_ROUND_UP(size, PAGE_SIZE);
|
||||
isert_buf->sg = kmalloc_array(isert_buf->sg_cnt, sizeof(*isert_buf->sg),
|
||||
GFP_KERNEL);
|
||||
isert_buf->sg = kmalloc_objs(*isert_buf->sg, isert_buf->sg_cnt);
|
||||
if (unlikely(!isert_buf->sg)) {
|
||||
PRINT_ERROR("Failed to allocate buffer SG");
|
||||
res = -ENOMEM;
|
||||
@@ -109,7 +108,7 @@ static int isert_buf_malloc(struct ib_device *ib_dev,
|
||||
int res = 0;
|
||||
|
||||
isert_buf->sg_cnt = 1;
|
||||
isert_buf->sg = kmalloc(sizeof(isert_buf->sg[0]), GFP_KERNEL);
|
||||
isert_buf->sg = kmalloc_obj(isert_buf->sg[0]);
|
||||
if (unlikely(!isert_buf->sg)) {
|
||||
PRINT_ERROR("Failed to allocate buffer SG");
|
||||
res = -ENOMEM;
|
||||
|
||||
@@ -171,14 +171,14 @@ static int isert_alloc_for_rdma(struct isert_cmnd *pdu, int sge_cnt,
|
||||
int i, ret = 0;
|
||||
int wr_cnt;
|
||||
|
||||
sg_pool = kmalloc_array(sge_cnt, sizeof(*sg_pool), GFP_KERNEL);
|
||||
sg_pool = kmalloc_objs(*sg_pool, sge_cnt);
|
||||
if (unlikely(!sg_pool)) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
wr_cnt = DIV_ROUND_UP(sge_cnt, isert_conn->max_sge);
|
||||
wr = kmalloc_array(wr_cnt, sizeof(*wr), GFP_KERNEL);
|
||||
wr = kmalloc_objs(*wr, wr_cnt);
|
||||
if (unlikely(!wr)) {
|
||||
ret = -ENOMEM;
|
||||
goto out_free_sg_pool;
|
||||
|
||||
@@ -905,7 +905,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
isert_dev = kzalloc(sizeof(*isert_dev), GFP_KERNEL);
|
||||
isert_dev = kzalloc_obj(*isert_dev);
|
||||
if (unlikely(!isert_dev)) {
|
||||
PRINT_ERROR("Failed to allocate iser dev");
|
||||
err = -ENOMEM;
|
||||
@@ -924,9 +924,8 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
|
||||
|
||||
isert_dev->num_cqs = blk_mq_num_online_queues(ib_dev->num_comp_vectors);
|
||||
|
||||
isert_dev->cq_qps = kcalloc(isert_dev->num_cqs,
|
||||
sizeof(*isert_dev->cq_qps),
|
||||
GFP_KERNEL);
|
||||
isert_dev->cq_qps = kzalloc_objs(*isert_dev->cq_qps,
|
||||
isert_dev->num_cqs);
|
||||
if (unlikely(!isert_dev->cq_qps)) {
|
||||
PRINT_ERROR("Failed to allocate %d iser cq_qps",
|
||||
isert_dev->num_cqs);
|
||||
@@ -1780,7 +1779,7 @@ struct isert_portal *isert_portal_create(struct sockaddr *sa, size_t addr_len)
|
||||
goto out;
|
||||
}
|
||||
|
||||
portal = kzalloc(sizeof(*portal), GFP_KERNEL);
|
||||
portal = kzalloc_obj(*portal);
|
||||
if (unlikely(!portal)) {
|
||||
PRINT_ERROR("Unable to allocate struct portal");
|
||||
portal = ERR_PTR(-ENOMEM);
|
||||
|
||||
@@ -990,8 +990,7 @@ int __init isert_init_login_devs(unsigned int ndevs)
|
||||
* allocate the devices -- we can't have them static, as the number
|
||||
* can be specified at load time
|
||||
*/
|
||||
isert_conn_devices = kcalloc(n_devs, sizeof(struct isert_conn_dev),
|
||||
GFP_KERNEL);
|
||||
isert_conn_devices = kzalloc_objs(struct isert_conn_dev, n_devs);
|
||||
if (unlikely(!isert_conn_devices)) {
|
||||
res = -ENOMEM;
|
||||
goto fail; /* Make this more graceful */
|
||||
|
||||
@@ -156,7 +156,7 @@ int __add_session(struct iscsi_target *target, struct iscsi_kern_session_info *i
|
||||
goto out_err_unlock;
|
||||
}
|
||||
|
||||
params_info = kmalloc(sizeof(*params_info), GFP_KERNEL);
|
||||
params_info = kmalloc_obj(*params_info);
|
||||
if (!params_info) {
|
||||
PRINT_ERROR("Unable to allocate params info (size %zd)",
|
||||
sizeof(*params_info));
|
||||
|
||||
@@ -84,7 +84,7 @@ static int iscsi_target_create(struct iscsi_kern_target_info *info, u32 tid,
|
||||
goto out;
|
||||
}
|
||||
|
||||
target = kzalloc(sizeof(*target), GFP_KERNEL);
|
||||
target = kzalloc_obj(*target);
|
||||
if (!target) {
|
||||
err = -ENOMEM;
|
||||
goto out_put;
|
||||
@@ -157,7 +157,7 @@ int __add_target(struct iscsi_kern_target_info *info)
|
||||
goto out;
|
||||
}
|
||||
|
||||
add_info = kmalloc(sizeof(*add_info), GFP_KERNEL);
|
||||
add_info = kmalloc_obj(*add_info);
|
||||
if (!add_info) {
|
||||
PRINT_ERROR("Unable to allocate additional info (size %zd)",
|
||||
sizeof(*add_info));
|
||||
|
||||
@@ -790,7 +790,7 @@ static int sqa_qla2xxx_check_initiator_node_acl(scsi_qla_host_t *vha,
|
||||
PRINT_INFO("sqatgt(%ld/%d): Registering initiator: pwwn=%8phC",
|
||||
vha->host_no, vha->vp_idx, fc_wwpn);
|
||||
|
||||
se_sess = kzalloc(sizeof(*se_sess), GFP_KERNEL);
|
||||
se_sess = kzalloc_obj(*se_sess);
|
||||
if (!se_sess)
|
||||
return res;
|
||||
|
||||
@@ -1327,7 +1327,7 @@ static int sqa_init_scst_tgt(struct scsi_qla_host *vha)
|
||||
if (res)
|
||||
goto done;
|
||||
|
||||
sqa_tgt = kzalloc(sizeof(*sqa_tgt), GFP_KERNEL);
|
||||
sqa_tgt = kzalloc_obj(*sqa_tgt);
|
||||
if (!sqa_tgt) {
|
||||
PRINT_ERROR("sqatgt(%ld/%d): alloc sqa_tgt failed",
|
||||
vha->host_no, vha->vp_idx);
|
||||
@@ -2083,7 +2083,7 @@ static void sqa_on_abort_cmd(struct scst_cmd *scst_cmd)
|
||||
* acquired in the reverse order elsewhere. Use a workqueue to avoid
|
||||
* acquiring the locks in the wrong order here.
|
||||
*/
|
||||
abort_work = kmalloc(sizeof(*abort_work), GFP_ATOMIC);
|
||||
abort_work = kmalloc_obj(*abort_work, GFP_ATOMIC);
|
||||
if (!abort_work)
|
||||
return;
|
||||
scst_cmd_get(scst_cmd);
|
||||
|
||||
@@ -2398,7 +2398,7 @@ qla2x00_do_dport_diagnostics(BSG_JOB_TYPE *bsg_job)
|
||||
!IS_QLA28XX(vha->hw))
|
||||
return -EPERM;
|
||||
|
||||
dd = kmalloc(sizeof(*dd), GFP_KERNEL);
|
||||
dd = kmalloc_obj(*dd);
|
||||
if (!dd) {
|
||||
ql_log(ql_log_warn, vha, 0x70db,
|
||||
"Failed to allocate memory for dport.\n");
|
||||
@@ -2444,7 +2444,7 @@ qla2x00_do_dport_diagnostics_v2(BSG_JOB_TYPE *bsg_job)
|
||||
if (!IS_DPORT_CAPABLE(vha->hw))
|
||||
return -EPERM;
|
||||
|
||||
dd = kzalloc(sizeof(*dd), GFP_KERNEL);
|
||||
dd = kzalloc_obj(*dd);
|
||||
if (!dd)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -2601,7 +2601,7 @@ qla2x00_manage_host_stats(BSG_JOB_TYPE *bsg_job)
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
req_data = kzalloc(sizeof(*req_data), GFP_KERNEL);
|
||||
req_data = kzalloc_obj(*req_data);
|
||||
if (!req_data) {
|
||||
ql_log(ql_log_warn, vha, 0x0000, "req_data memory allocation failure.\n");
|
||||
return -ENOMEM;
|
||||
@@ -2672,7 +2672,7 @@ qla2x00_get_host_stats(BSG_JOB_TYPE *bsg_job)
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
req_data = kzalloc(sizeof(*req_data), GFP_KERNEL);
|
||||
req_data = kzalloc_obj(*req_data);
|
||||
if (!req_data) {
|
||||
ql_log(ql_log_warn, vha, 0x0000, "req_data memory allocation failure.\n");
|
||||
return -ENOMEM;
|
||||
@@ -2779,7 +2779,7 @@ qla2x00_get_tgt_stats(BSG_JOB_TYPE *bsg_job)
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
req_data = kzalloc(sizeof(*req_data), GFP_KERNEL);
|
||||
req_data = kzalloc_obj(*req_data);
|
||||
if (!req_data) {
|
||||
ql_log(ql_log_warn, vha, 0x0000, "req_data memory allocation failure.\n");
|
||||
return -ENOMEM;
|
||||
@@ -2862,7 +2862,7 @@ qla2x00_manage_host_port(BSG_JOB_TYPE *bsg_job)
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
req_data = kzalloc(sizeof(*req_data), GFP_KERNEL);
|
||||
req_data = kzalloc_obj(*req_data);
|
||||
if (!req_data) {
|
||||
ql_log(ql_log_warn, vha, 0x0000, "req_data memory allocation failure.\n");
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -173,7 +173,7 @@ static int qla_edif_list_add_sa_update_index(fc_port_t *fcport,
|
||||
* when update is called for the first two sa_indexes
|
||||
* followed by a delete of the first sa_index
|
||||
*/
|
||||
entry = kzalloc((sizeof(struct edif_list_entry)), GFP_ATOMIC);
|
||||
entry = kzalloc_obj(struct edif_list_entry, GFP_ATOMIC);
|
||||
if (!entry)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -1393,7 +1393,7 @@ qla_edif_add_sa_ctl(fc_port_t *fcport, struct qla_sa_update_frame *sa_frame,
|
||||
int index = sa_frame->fast_sa_index;
|
||||
unsigned long flags = 0;
|
||||
|
||||
sa_ctl = kzalloc(sizeof(*sa_ctl), GFP_KERNEL);
|
||||
sa_ctl = kzalloc_obj(*sa_ctl);
|
||||
if (!sa_ctl) {
|
||||
/* couldn't get space */
|
||||
ql_dbg(ql_dbg_edif, fcport->vha, 0x9100,
|
||||
@@ -2187,7 +2187,7 @@ qla_edb_node_alloc(scsi_qla_host_t *vha, uint32_t ntype)
|
||||
{
|
||||
struct edb_node *node;
|
||||
|
||||
node = kzalloc(sizeof(*node), GFP_ATOMIC);
|
||||
node = kzalloc_obj(*node, GFP_ATOMIC);
|
||||
if (!node) {
|
||||
/* couldn't get space */
|
||||
ql_dbg(ql_dbg_edif, vha, 0x9100,
|
||||
@@ -3279,7 +3279,7 @@ static uint16_t qla_edif_sadb_get_sa_index(fc_port_t *fcport,
|
||||
}
|
||||
|
||||
/* if there is no entry for this nport, add one */
|
||||
entry = kzalloc((sizeof(struct edif_sa_index_entry)), GFP_ATOMIC);
|
||||
entry = kzalloc_obj(struct edif_sa_index_entry, GFP_ATOMIC);
|
||||
if (!entry)
|
||||
return INVALID_EDIF_SA_INDEX;
|
||||
|
||||
@@ -3381,7 +3381,7 @@ void qla_edif_sadb_release(struct qla_hw_data *ha)
|
||||
int qla_edif_sadb_build_free_pool(struct qla_hw_data *ha)
|
||||
{
|
||||
ha->edif_tx_sa_id_map =
|
||||
kcalloc(BITS_TO_LONGS(EDIF_NUM_SA_INDEX), sizeof(long), GFP_KERNEL);
|
||||
kzalloc_objs(long, BITS_TO_LONGS(EDIF_NUM_SA_INDEX));
|
||||
|
||||
if (!ha->edif_tx_sa_id_map) {
|
||||
ql_log_pci(ql_log_fatal, ha->pdev, 0x0009,
|
||||
@@ -3390,7 +3390,7 @@ int qla_edif_sadb_build_free_pool(struct qla_hw_data *ha)
|
||||
}
|
||||
|
||||
ha->edif_rx_sa_id_map =
|
||||
kcalloc(BITS_TO_LONGS(EDIF_NUM_SA_INDEX), sizeof(long), GFP_KERNEL);
|
||||
kzalloc_objs(long, BITS_TO_LONGS(EDIF_NUM_SA_INDEX));
|
||||
if (!ha->edif_rx_sa_id_map) {
|
||||
kfree(ha->edif_tx_sa_id_map);
|
||||
ha->edif_tx_sa_id_map = NULL;
|
||||
|
||||
@@ -4036,9 +4036,8 @@ qla2x00_alloc_outstanding_cmds(struct qla_hw_data *ha, struct req_que *req)
|
||||
req->num_outstanding_cmds = ha->cur_fw_iocb_count;
|
||||
}
|
||||
|
||||
req->outstanding_cmds = kcalloc(req->num_outstanding_cmds,
|
||||
sizeof(srb_t *),
|
||||
GFP_KERNEL);
|
||||
req->outstanding_cmds = kzalloc_objs(srb_t *,
|
||||
req->num_outstanding_cmds);
|
||||
|
||||
if (!req->outstanding_cmds) {
|
||||
/*
|
||||
@@ -4046,9 +4045,8 @@ qla2x00_alloc_outstanding_cmds(struct qla_hw_data *ha, struct req_que *req)
|
||||
* initialization.
|
||||
*/
|
||||
req->num_outstanding_cmds = MIN_OUTSTANDING_COMMANDS;
|
||||
req->outstanding_cmds = kcalloc(req->num_outstanding_cmds,
|
||||
sizeof(srb_t *),
|
||||
GFP_KERNEL);
|
||||
req->outstanding_cmds = kzalloc_objs(srb_t *,
|
||||
req->num_outstanding_cmds);
|
||||
|
||||
if (!req->outstanding_cmds) {
|
||||
ql_log(ql_log_fatal, NULL, 0x0126,
|
||||
@@ -5577,7 +5575,7 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags)
|
||||
{
|
||||
fc_port_t *fcport;
|
||||
|
||||
fcport = kzalloc(sizeof(fc_port_t), flags);
|
||||
fcport = kzalloc_obj(fc_port_t, flags);
|
||||
if (!fcport)
|
||||
return NULL;
|
||||
|
||||
@@ -6497,8 +6495,7 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha)
|
||||
|
||||
/* Try GID_PT to get device list, else GAN. */
|
||||
if (!ha->swl)
|
||||
ha->swl = kcalloc(ha->max_fibre_devices, sizeof(sw_info_t),
|
||||
GFP_KERNEL);
|
||||
ha->swl = kzalloc_objs(sw_info_t, ha->max_fibre_devices);
|
||||
swl = ha->swl;
|
||||
if (!swl) {
|
||||
/*EMPTY*/
|
||||
@@ -9234,7 +9231,7 @@ qla84xx_get_chip(struct scsi_qla_host *vha)
|
||||
}
|
||||
}
|
||||
|
||||
cs84xx = kzalloc(sizeof(*cs84xx), GFP_KERNEL);
|
||||
cs84xx = kzalloc_obj(*cs84xx);
|
||||
if (!cs84xx)
|
||||
goto done;
|
||||
|
||||
@@ -9888,7 +9885,7 @@ struct qla_qpair *qla2xxx_create_qpair(struct scsi_qla_host *vha, int qos,
|
||||
}
|
||||
|
||||
if (ql2xmqsupport || ql2xnvmeenable) {
|
||||
qpair = kzalloc(sizeof(struct qla_qpair), GFP_KERNEL);
|
||||
qpair = kzalloc_obj(struct qla_qpair);
|
||||
if (qpair == NULL) {
|
||||
ql_log(ql_log_warn, vha, 0x0182,
|
||||
"Failed to allocate memory for queue pair.\n");
|
||||
|
||||
@@ -633,8 +633,7 @@ static inline int qla_mapq_alloc_qp_cpu_map(struct qla_hw_data *ha)
|
||||
scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
|
||||
|
||||
if (!ha->qp_cpu_map) {
|
||||
ha->qp_cpu_map = kcalloc(NR_CPUS, sizeof(struct qla_qpair *),
|
||||
GFP_KERNEL);
|
||||
ha->qp_cpu_map = kzalloc_objs(struct qla_qpair *, NR_CPUS);
|
||||
if (!ha->qp_cpu_map) {
|
||||
ql_log(ql_log_fatal, vha, 0x0180,
|
||||
"Unable to allocate memory for qp_cpu_map ptrs.\n");
|
||||
|
||||
@@ -892,7 +892,7 @@ alloc_and_fill:
|
||||
used_dsds -= avail_dsds;
|
||||
|
||||
/* allocate tracking DS */
|
||||
dsd_ptr = kzalloc(sizeof(struct dsd_dma), GFP_ATOMIC);
|
||||
dsd_ptr = kzalloc_obj(struct dsd_dma, GFP_ATOMIC);
|
||||
if (!dsd_ptr)
|
||||
return 1;
|
||||
|
||||
@@ -989,7 +989,7 @@ qla24xx_walk_and_build_sglist(struct qla_hw_data *ha, srb_t *sp,
|
||||
used_dsds -= avail_dsds;
|
||||
|
||||
/* allocate tracking DS */
|
||||
dsd_ptr = kzalloc(sizeof(struct dsd_dma), GFP_ATOMIC);
|
||||
dsd_ptr = kzalloc_obj(struct dsd_dma, GFP_ATOMIC);
|
||||
if (!dsd_ptr)
|
||||
return 1;
|
||||
|
||||
@@ -1134,8 +1134,8 @@ qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp,
|
||||
* Allocate list item to store
|
||||
* the DMA buffers
|
||||
*/
|
||||
dsd_ptr = kzalloc(sizeof(*dsd_ptr),
|
||||
GFP_ATOMIC);
|
||||
dsd_ptr = kzalloc_obj(*dsd_ptr,
|
||||
GFP_ATOMIC);
|
||||
if (!dsd_ptr) {
|
||||
ql_dbg(ql_dbg_tgt, vha, 0xe024,
|
||||
"%s: failed alloc dsd_ptr\n",
|
||||
@@ -1220,7 +1220,7 @@ qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp,
|
||||
used_dsds -= avail_dsds;
|
||||
|
||||
/* allocate tracking DS */
|
||||
dsd_ptr = kzalloc(sizeof(*dsd_ptr), GFP_ATOMIC);
|
||||
dsd_ptr = kzalloc_obj(*dsd_ptr, GFP_ATOMIC);
|
||||
if (!dsd_ptr) {
|
||||
ql_dbg(ql_dbg_tgt, vha, 0xe026,
|
||||
"%s: failed alloc dsd_ptr\n",
|
||||
@@ -1286,7 +1286,7 @@ qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp,
|
||||
used_dsds -= avail_dsds;
|
||||
|
||||
/* allocate tracking DS */
|
||||
dsd_ptr = kzalloc(sizeof(*dsd_ptr), GFP_ATOMIC);
|
||||
dsd_ptr = kzalloc_obj(*dsd_ptr, GFP_ATOMIC);
|
||||
if (!dsd_ptr) {
|
||||
ql_dbg(ql_dbg_tgt + ql_dbg_verbose,
|
||||
vha, 0xe027,
|
||||
@@ -3464,7 +3464,7 @@ qla82xx_start_scsi(srb_t *sp)
|
||||
more_dsd_lists -= qpair->dsd_avail;
|
||||
|
||||
for (i = 0; i < more_dsd_lists; i++) {
|
||||
dsd_ptr = kzalloc(sizeof(struct dsd_dma), GFP_ATOMIC);
|
||||
dsd_ptr = kzalloc_obj(struct dsd_dma, GFP_ATOMIC);
|
||||
if (!dsd_ptr) {
|
||||
ql_log(ql_log_fatal, vha, 0x300e,
|
||||
"Failed to allocate memory for dsd_dma "
|
||||
@@ -4330,7 +4330,7 @@ qla_start_scsi_type6(srb_t *sp)
|
||||
more_dsd_lists -= qpair->dsd_avail;
|
||||
|
||||
for (i = 0; i < more_dsd_lists; i++) {
|
||||
dsd_ptr = kzalloc(sizeof(*dsd_ptr), GFP_ATOMIC);
|
||||
dsd_ptr = kzalloc_obj(*dsd_ptr, GFP_ATOMIC);
|
||||
if (!dsd_ptr) {
|
||||
ql_log(ql_log_fatal, vha, 0x3029,
|
||||
"Failed to allocate memory for dsd_dma for cmd=%p.\n", cmd);
|
||||
|
||||
@@ -4559,8 +4559,7 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
|
||||
struct msix_entry *entries;
|
||||
|
||||
entries = kcalloc(ha->msix_count, sizeof(struct msix_entry),
|
||||
GFP_KERNEL);
|
||||
entries = kzalloc_objs(struct msix_entry, ha->msix_count);
|
||||
if (!entries) {
|
||||
ql_log(ql_log_warn, vha, 0x00bc,
|
||||
"Failed to allocate memory for msix_entry.\n");
|
||||
@@ -4662,9 +4661,7 @@ msix_failed:
|
||||
#else
|
||||
vha->irq_offset = min_vecs;
|
||||
#endif
|
||||
ha->msix_entries = kcalloc(ha->msix_count,
|
||||
sizeof(struct qla_msix_entry),
|
||||
GFP_KERNEL);
|
||||
ha->msix_entries = kzalloc_objs(struct qla_msix_entry, ha->msix_count);
|
||||
if (!ha->msix_entries) {
|
||||
ql_log(ql_log_fatal, vha, 0x00c8,
|
||||
"Failed to allocate memory for ha->msix_entries.\n");
|
||||
|
||||
@@ -707,7 +707,7 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
|
||||
device_reg_t *reg;
|
||||
uint32_t cnt;
|
||||
|
||||
req = kzalloc(sizeof(struct req_que), GFP_KERNEL);
|
||||
req = kzalloc_obj(struct req_que);
|
||||
if (req == NULL) {
|
||||
ql_log(ql_log_fatal, base_vha, 0x00d9,
|
||||
"Failed to allocate memory for request queue.\n");
|
||||
@@ -834,7 +834,7 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
|
||||
uint16_t que_id = 0;
|
||||
device_reg_t *reg;
|
||||
|
||||
rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL);
|
||||
rsp = kzalloc_obj(struct rsp_que);
|
||||
if (rsp == NULL) {
|
||||
ql_log(ql_log_warn, base_vha, 0x0066,
|
||||
"Failed to allocate memory for response queue.\n");
|
||||
@@ -1102,7 +1102,7 @@ int qla_create_buf_pool(struct scsi_qla_host *vha, struct qla_qpair *qp)
|
||||
return -ENOMEM;
|
||||
}
|
||||
sz = qp->req->length * sizeof(dma_addr_t);
|
||||
qp->buf_pool.dma_array = kcalloc(qp->req->length, sizeof(dma_addr_t), GFP_KERNEL);
|
||||
qp->buf_pool.dma_array = kzalloc_objs(dma_addr_t, qp->req->length);
|
||||
if (!qp->buf_pool.dma_array) {
|
||||
ql_log(ql_log_warn, vha, 0x0186,
|
||||
"Failed to allocate dma_array(%d).\n", sz);
|
||||
|
||||
@@ -1251,7 +1251,7 @@ void qla2xxx_process_purls_iocb(void **pkt, struct rsp_que **rsp)
|
||||
goto out;
|
||||
}
|
||||
|
||||
uctx = kzalloc(sizeof(*uctx), GFP_ATOMIC);
|
||||
uctx = kzalloc_obj(*uctx, GFP_ATOMIC);
|
||||
if (!uctx) {
|
||||
ql_log(ql_log_info, vha, 0x2126, "Failed allocate memory\n");
|
||||
a.reason = FCNVME_RJT_RC_LOGIC;
|
||||
|
||||
@@ -1190,7 +1190,7 @@ qla82xx_pinit_from_rom(scsi_qla_host_t *vha)
|
||||
ql_log(ql_log_info, vha, 0x0072,
|
||||
"%d CRB init values found in ROM.\n", n);
|
||||
|
||||
buf = kmalloc_array(n, sizeof(struct crb_addr_pair), GFP_KERNEL);
|
||||
buf = kmalloc_objs(struct crb_addr_pair, n);
|
||||
if (buf == NULL) {
|
||||
ql_log(ql_log_fatal, vha, 0x010c,
|
||||
"Unable to allocate memory.\n");
|
||||
|
||||
+16
-20
@@ -487,23 +487,21 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req,
|
||||
{
|
||||
scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
|
||||
|
||||
ha->req_q_map = kcalloc(ha->max_req_queues, sizeof(struct req_que *),
|
||||
GFP_KERNEL);
|
||||
ha->req_q_map = kzalloc_objs(struct req_que *, ha->max_req_queues);
|
||||
if (!ha->req_q_map) {
|
||||
ql_log(ql_log_fatal, vha, 0x003b,
|
||||
"Unable to allocate memory for request queue ptrs.\n");
|
||||
goto fail_req_map;
|
||||
}
|
||||
|
||||
ha->rsp_q_map = kcalloc(ha->max_rsp_queues, sizeof(struct rsp_que *),
|
||||
GFP_KERNEL);
|
||||
ha->rsp_q_map = kzalloc_objs(struct rsp_que *, ha->max_rsp_queues);
|
||||
if (!ha->rsp_q_map) {
|
||||
ql_log(ql_log_fatal, vha, 0x003c,
|
||||
"Unable to allocate memory for response queue ptrs.\n");
|
||||
goto fail_rsp_map;
|
||||
}
|
||||
|
||||
ha->base_qpair = kzalloc(sizeof(struct qla_qpair), GFP_KERNEL);
|
||||
ha->base_qpair = kzalloc_obj(struct qla_qpair);
|
||||
if (ha->base_qpair == NULL) {
|
||||
ql_log(ql_log_warn, vha, 0x00e0,
|
||||
"Failed to allocate base queue pair memory.\n");
|
||||
@@ -513,8 +511,8 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req,
|
||||
qla_init_base_qpair(vha, req, rsp);
|
||||
|
||||
if ((ql2xmqsupport || ql2xnvmeenable) && ha->max_qpairs) {
|
||||
ha->queue_pair_map = kcalloc(ha->max_qpairs, sizeof(struct qla_qpair *),
|
||||
GFP_KERNEL);
|
||||
ha->queue_pair_map = kzalloc_objs(struct qla_qpair *,
|
||||
ha->max_qpairs);
|
||||
if (!ha->queue_pair_map) {
|
||||
ql_log(ql_log_fatal, vha, 0x0180,
|
||||
"Unable to allocate memory for queue pair ptrs.\n");
|
||||
@@ -3076,7 +3074,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||
pci_enable_pcie_error_reporting(pdev);
|
||||
#endif
|
||||
|
||||
ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL);
|
||||
ha = kzalloc_obj(struct qla_hw_data);
|
||||
if (!ha) {
|
||||
ql_log_pci(ql_log_fatal, pdev, 0x0009,
|
||||
"Unable to allocate memory for ha.\n");
|
||||
@@ -4283,7 +4281,8 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
|
||||
int rc;
|
||||
|
||||
if (QLA_TGT_MODE_ENABLED() || EDIF_CAP(ha)) {
|
||||
ha->vp_map = kcalloc(MAX_MULTI_ID_FABRIC, sizeof(struct qla_vp_map), GFP_KERNEL);
|
||||
ha->vp_map = kzalloc_objs(struct qla_vp_map,
|
||||
MAX_MULTI_ID_FABRIC);
|
||||
if (!ha->vp_map)
|
||||
goto fail;
|
||||
}
|
||||
@@ -4379,7 +4378,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
|
||||
ha->pool.good.count = 0;
|
||||
ha->pool.unusable.count = 0;
|
||||
for (i = 0; i < 128; i++) {
|
||||
dsd = kzalloc(sizeof(*dsd), GFP_ATOMIC);
|
||||
dsd = kzalloc_obj(*dsd, GFP_ATOMIC);
|
||||
if (!dsd) {
|
||||
ql_dbg_pci(ql_dbg_init, ha->pdev,
|
||||
0xe0ee, "%s: failed alloc dsd\n",
|
||||
@@ -4467,7 +4466,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
|
||||
}
|
||||
|
||||
/* Allocate memory for request ring */
|
||||
*req = kzalloc(sizeof(struct req_que), GFP_KERNEL);
|
||||
*req = kzalloc_obj(struct req_que);
|
||||
if (!*req) {
|
||||
ql_log_pci(ql_log_fatal, ha->pdev, 0x0028,
|
||||
"Failed to allocate memory for req.\n");
|
||||
@@ -4483,7 +4482,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
|
||||
goto fail_req_ring;
|
||||
}
|
||||
/* Allocate memory for response ring */
|
||||
*rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL);
|
||||
*rsp = kzalloc_obj(struct rsp_que);
|
||||
if (!*rsp) {
|
||||
ql_log_pci(ql_log_fatal, ha->pdev, 0x002a,
|
||||
"Failed to allocate memory for rsp.\n");
|
||||
@@ -4508,9 +4507,8 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
|
||||
(*rsp)->ring);
|
||||
/* Allocate memory for NVRAM data for vports */
|
||||
if (ha->nvram_npiv_size) {
|
||||
ha->npiv_info = kcalloc(ha->nvram_npiv_size,
|
||||
sizeof(struct qla_npiv_entry),
|
||||
GFP_KERNEL);
|
||||
ha->npiv_info = kzalloc_objs(struct qla_npiv_entry,
|
||||
ha->nvram_npiv_size);
|
||||
if (!ha->npiv_info) {
|
||||
ql_log_pci(ql_log_fatal, ha->pdev, 0x002d,
|
||||
"Failed to allocate memory for npiv_info.\n");
|
||||
@@ -4554,9 +4552,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
|
||||
INIT_LIST_HEAD(&ha->vp_list);
|
||||
|
||||
/* Allocate memory for our loop_id bitmap */
|
||||
ha->loop_id_map = kcalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE),
|
||||
sizeof(long),
|
||||
GFP_KERNEL);
|
||||
ha->loop_id_map = kzalloc_objs(long, BITS_TO_LONGS(LOOPID_MAP_SIZE));
|
||||
if (!ha->loop_id_map)
|
||||
goto fail_loop_id_map;
|
||||
else {
|
||||
@@ -5275,7 +5271,7 @@ qla2x00_alloc_work(struct scsi_qla_host *vha, enum qla_work_type type)
|
||||
if (qla_vha_mark_busy(vha))
|
||||
return NULL;
|
||||
|
||||
e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC);
|
||||
e = kzalloc_obj(struct qla_work_evt, GFP_ATOMIC);
|
||||
if (!e) {
|
||||
QLA_VHA_MARK_NOT_BUSY(vha);
|
||||
return NULL;
|
||||
@@ -6161,7 +6157,7 @@ qla25xx_rdp_rsp_reduce_size(struct scsi_qla_host *vha,
|
||||
|
||||
ql_dbg(ql_dbg_init, vha, 0x0181, "%s: s_id=%#x\n", __func__, sid);
|
||||
|
||||
pdb = kzalloc(sizeof(*pdb), GFP_KERNEL);
|
||||
pdb = kzalloc_obj(*pdb);
|
||||
if (!pdb) {
|
||||
ql_dbg(ql_dbg_init, vha, 0x0181,
|
||||
"%s: Failed allocate pdb\n", __func__);
|
||||
|
||||
@@ -1636,7 +1636,7 @@ static int qlt_sched_sess_work(struct qla_tgt *tgt, int type,
|
||||
struct qla_tgt_sess_work_param *prm;
|
||||
unsigned long flags;
|
||||
|
||||
prm = kzalloc(sizeof(*prm), GFP_ATOMIC);
|
||||
prm = kzalloc_obj(*prm, GFP_ATOMIC);
|
||||
if (!prm) {
|
||||
ql_dbg(ql_dbg_tgt_mgt, tgt->vha, 0xf050,
|
||||
"qla_target(%d): Unable to create session "
|
||||
@@ -4041,7 +4041,7 @@ static int qlt_prepare_srr_ctio(struct qla_qpair *qpair,
|
||||
return 0;
|
||||
}
|
||||
|
||||
srr = kzalloc(sizeof(*srr), GFP_ATOMIC);
|
||||
srr = kzalloc_obj(*srr, GFP_ATOMIC);
|
||||
if (!srr)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -5632,7 +5632,7 @@ static void qlt_prepare_srr_imm(struct scsi_qla_host *vha,
|
||||
* safely.
|
||||
*/
|
||||
|
||||
srr = kzalloc(sizeof(*srr), GFP_ATOMIC);
|
||||
srr = kzalloc_obj(*srr, GFP_ATOMIC);
|
||||
if (!srr)
|
||||
goto out_reject;
|
||||
|
||||
@@ -5778,7 +5778,7 @@ static int qlt_set_data_offset(struct qla_tgt_cmd *cmd, uint32_t offset)
|
||||
*/
|
||||
int n_alloc_sg = min(sg_srr_cnt, 2);
|
||||
struct scatterlist *sg_srr =
|
||||
kmalloc_array(n_alloc_sg, sizeof(*sg_srr), GFP_ATOMIC);
|
||||
kmalloc_objs(*sg_srr, n_alloc_sg, GFP_ATOMIC);
|
||||
if (!sg_srr) {
|
||||
ql_dbg(ql_dbg_tgt_mgt, vha, 0x11027,
|
||||
"qla_target(%d): tag %lld: Unable to allocate SRR scatterlist\n",
|
||||
@@ -7529,16 +7529,14 @@ int qlt_add_target(struct qla_hw_data *ha, struct scsi_qla_host *base_vha)
|
||||
|
||||
BUG_ON(base_vha->vha_tgt.qla_tgt != NULL);
|
||||
|
||||
tgt = kzalloc(sizeof(struct qla_tgt), GFP_KERNEL);
|
||||
tgt = kzalloc_obj(struct qla_tgt);
|
||||
if (!tgt) {
|
||||
ql_dbg(ql_dbg_tgt, base_vha, 0xe066,
|
||||
"Unable to allocate struct qla_tgt\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
tgt->qphints = kcalloc(ha->max_qpairs + 1,
|
||||
sizeof(struct qla_qpair_hint),
|
||||
GFP_KERNEL);
|
||||
tgt->qphints = kzalloc_objs(struct qla_qpair_hint, ha->max_qpairs + 1);
|
||||
if (!tgt->qphints) {
|
||||
kfree(tgt);
|
||||
ql_log(ql_log_warn, base_vha, 0x0197,
|
||||
@@ -8351,7 +8349,7 @@ qlt_handle_abts_recv(struct scsi_qla_host *vha, struct rsp_que *rsp,
|
||||
{
|
||||
struct qla_tgt_sess_op *op;
|
||||
|
||||
op = kzalloc(sizeof(*op), GFP_ATOMIC);
|
||||
op = kzalloc_obj(*op, GFP_ATOMIC);
|
||||
|
||||
if (!op) {
|
||||
/* do not reach for ATIO queue here. This is best effort err
|
||||
|
||||
@@ -1244,7 +1244,7 @@ retry:
|
||||
|
||||
TRACE_DBG("loop_id 0x%x", loop_id);
|
||||
|
||||
fcport = kzalloc(sizeof(*fcport), GFP_KERNEL);
|
||||
fcport = kzalloc_obj(*fcport);
|
||||
if (fcport == NULL) {
|
||||
PRINT_ERROR("qla2x00t(%ld): Allocation of tmp FC port failed",
|
||||
vha->host_no);
|
||||
@@ -1749,7 +1749,7 @@ static int q2t_sched_sess_work(struct q2t_tgt *tgt, int type,
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
prm = kzalloc(sizeof(*prm), GFP_ATOMIC);
|
||||
prm = kzalloc_obj(*prm, GFP_ATOMIC);
|
||||
if (prm == NULL) {
|
||||
PRINT_ERROR("qla2x00t(%ld): Unable to create session "
|
||||
"work, command will be refused", tgt->vha->host_no);
|
||||
@@ -3561,7 +3561,7 @@ static int q2t_prepare_srr_ctio(scsi_qla_host_t *vha, struct q2t_cmd *cmd,
|
||||
|
||||
scst_update_hw_pending_start(&cmd->scst_cmd);
|
||||
|
||||
sc = kzalloc(sizeof(*sc), GFP_ATOMIC);
|
||||
sc = kzalloc_obj(*sc, GFP_ATOMIC);
|
||||
if (sc != NULL) {
|
||||
sc->cmd = cmd;
|
||||
/* IRQ is already OFF */
|
||||
@@ -4560,7 +4560,7 @@ static int q2t_cut_cmd_data_head(struct q2t_cmd *cmd, unsigned int offset)
|
||||
first_sg, first_page, first_page_offs, cmd->bufflen,
|
||||
cmd->sg_cnt);
|
||||
|
||||
sg = kmalloc_array(cnt, sizeof(sg[0]), GFP_KERNEL);
|
||||
sg = kmalloc_objs(sg[0], cnt);
|
||||
if (sg == NULL) {
|
||||
PRINT_ERROR("qla2x00t(%ld): Unable to allocate cut "
|
||||
"SG (len %zd)", cmd->tgt->vha->host_no,
|
||||
@@ -4959,7 +4959,7 @@ static void q2t_prepare_srr_imm(scsi_qla_host_t *vha, void *iocb)
|
||||
|
||||
TRACE(TRACE_MGMT, "qla2x00t(%ld): SRR received", vha->host_no);
|
||||
|
||||
imm = kzalloc(sizeof(*imm), GFP_ATOMIC);
|
||||
imm = kzalloc_obj(*imm, GFP_ATOMIC);
|
||||
if (imm != NULL) {
|
||||
memcpy(&imm->imm.notify_entry, iocb,
|
||||
sizeof(imm->imm.notify_entry));
|
||||
@@ -5806,7 +5806,7 @@ retry:
|
||||
}
|
||||
}
|
||||
|
||||
fcport = kzalloc(sizeof(*fcport), GFP_KERNEL);
|
||||
fcport = kzalloc_obj(*fcport);
|
||||
if (fcport == NULL) {
|
||||
PRINT_ERROR("qla2x00t(%ld): Allocation of tmp FC port failed",
|
||||
vha->host_no);
|
||||
|
||||
+3
-4
@@ -2680,7 +2680,7 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags)
|
||||
{
|
||||
fc_port_t *fcport;
|
||||
|
||||
fcport = kzalloc(sizeof(fc_port_t), flags);
|
||||
fcport = kzalloc_obj(fc_port_t, flags);
|
||||
if (!fcport)
|
||||
return NULL;
|
||||
|
||||
@@ -3282,8 +3282,7 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
|
||||
|
||||
/* Try GID_PT to get device list, else GAN. */
|
||||
if (!ha->swl)
|
||||
ha->swl = kcalloc(ha->max_fibre_devices, sizeof(sw_info_t),
|
||||
GFP_KERNEL);
|
||||
ha->swl = kzalloc_objs(sw_info_t, ha->max_fibre_devices);
|
||||
swl = ha->swl;
|
||||
if (!swl) {
|
||||
/*EMPTY*/
|
||||
@@ -5308,7 +5307,7 @@ qla84xx_get_chip(struct scsi_qla_host *vha)
|
||||
}
|
||||
}
|
||||
|
||||
cs84xx = kzalloc(sizeof(*cs84xx), GFP_KERNEL);
|
||||
cs84xx = kzalloc_obj(*cs84xx);
|
||||
if (!cs84xx)
|
||||
goto done;
|
||||
|
||||
|
||||
+4
-4
@@ -1055,7 +1055,7 @@ alloc_and_fill:
|
||||
used_dsds -= avail_dsds;
|
||||
|
||||
/* allocate tracking DS */
|
||||
dsd_ptr = kzalloc(sizeof(struct dsd_dma), GFP_ATOMIC);
|
||||
dsd_ptr = kzalloc_obj(struct dsd_dma, GFP_ATOMIC);
|
||||
if (!dsd_ptr)
|
||||
return 1;
|
||||
|
||||
@@ -1139,7 +1139,7 @@ qla24xx_walk_and_build_sglist(struct qla_hw_data *ha, srb_t *sp, uint32_t *dsd,
|
||||
used_dsds -= avail_dsds;
|
||||
|
||||
/* allocate tracking DS */
|
||||
dsd_ptr = kzalloc(sizeof(struct dsd_dma), GFP_ATOMIC);
|
||||
dsd_ptr = kzalloc_obj(struct dsd_dma, GFP_ATOMIC);
|
||||
if (!dsd_ptr)
|
||||
return 1;
|
||||
|
||||
@@ -1219,7 +1219,7 @@ qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp,
|
||||
used_dsds -= avail_dsds;
|
||||
|
||||
/* allocate tracking DS */
|
||||
dsd_ptr = kzalloc(sizeof(struct dsd_dma), GFP_ATOMIC);
|
||||
dsd_ptr = kzalloc_obj(struct dsd_dma, GFP_ATOMIC);
|
||||
if (!dsd_ptr)
|
||||
return 1;
|
||||
|
||||
@@ -2391,7 +2391,7 @@ qla82xx_start_scsi(srb_t *sp)
|
||||
more_dsd_lists -= ha->gbl_dsd_avail;
|
||||
|
||||
for (i = 0; i < more_dsd_lists; i++) {
|
||||
dsd_ptr = kzalloc(sizeof(struct dsd_dma), GFP_ATOMIC);
|
||||
dsd_ptr = kzalloc_obj(struct dsd_dma, GFP_ATOMIC);
|
||||
if (!dsd_ptr) {
|
||||
ql_log(ql_log_fatal, vha, 0x300e,
|
||||
"Failed to allocate memory for dsd_dma "
|
||||
|
||||
+2
-4
@@ -2628,8 +2628,7 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
|
||||
struct qla_msix_entry *qentry;
|
||||
scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
|
||||
|
||||
entries = kcalloc(ha->msix_count, sizeof(struct msix_entry),
|
||||
GFP_KERNEL);
|
||||
entries = kzalloc_objs(struct msix_entry, ha->msix_count);
|
||||
if (!entries) {
|
||||
ql_log(ql_log_warn, vha, 0x00bc,
|
||||
"Failed to allocate memory for msix_entry.\n");
|
||||
@@ -2679,8 +2678,7 @@ msix_failed:
|
||||
ha->max_rsp_queues = ha->msix_count - 1;
|
||||
}
|
||||
#endif
|
||||
ha->msix_entries = kcalloc(ha->msix_count,
|
||||
sizeof(struct qla_msix_entry), GFP_KERNEL);
|
||||
ha->msix_entries = kzalloc_objs(struct qla_msix_entry, ha->msix_count);
|
||||
if (!ha->msix_entries) {
|
||||
ql_log(ql_log_fatal, vha, 0x00c8,
|
||||
"Failed to allocate memory for ha->msix_entries.\n");
|
||||
|
||||
+2
-2
@@ -691,7 +691,7 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
|
||||
uint16_t que_id = 0;
|
||||
uint32_t cnt;
|
||||
|
||||
req = kzalloc(sizeof(struct req_que), GFP_KERNEL);
|
||||
req = kzalloc_obj(struct req_que);
|
||||
if (req == NULL) {
|
||||
ql_log(ql_log_fatal, base_vha, 0x00d9,
|
||||
"Failed to allocate memory for request queue.\n");
|
||||
@@ -807,7 +807,7 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
|
||||
uint16_t que_id = 0;
|
||||
device_reg_t __iomem *reg;
|
||||
|
||||
rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL);
|
||||
rsp = kzalloc_obj(struct rsp_que);
|
||||
if (rsp == NULL) {
|
||||
ql_log(ql_log_warn, base_vha, 0x0066,
|
||||
"Failed to allocate memory for response queue.\n");
|
||||
|
||||
+1
-6
@@ -1093,11 +1093,6 @@ qla82xx_pinit_from_rom(scsi_qla_host_t *vha)
|
||||
unsigned offset, n;
|
||||
struct qla_hw_data *ha = vha->hw;
|
||||
|
||||
struct crb_addr_pair {
|
||||
long addr;
|
||||
long data;
|
||||
};
|
||||
|
||||
/* Halt all the indiviual PEGs and other blocks of the ISP */
|
||||
qla82xx_rom_lock(ha);
|
||||
|
||||
@@ -1181,7 +1176,7 @@ qla82xx_pinit_from_rom(scsi_qla_host_t *vha)
|
||||
ql_log(ql_log_info, vha, 0x0072,
|
||||
"%d CRB init values found in ROM.\n", n);
|
||||
|
||||
buf = kmalloc_array(n, sizeof(struct crb_addr_pair), GFP_KERNEL);
|
||||
buf = kmalloc_objs(struct crb_addr_pair, n);
|
||||
if (buf == NULL) {
|
||||
ql_log(ql_log_fatal, vha, 0x010c,
|
||||
"Unable to allocate memory.\n");
|
||||
|
||||
+10
-14
@@ -373,16 +373,14 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req,
|
||||
struct rsp_que *rsp)
|
||||
{
|
||||
scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
|
||||
ha->req_q_map = kcalloc(ha->max_req_queues, sizeof(struct req_que *),
|
||||
GFP_KERNEL);
|
||||
ha->req_q_map = kzalloc_objs(struct req_que *, ha->max_req_queues);
|
||||
if (!ha->req_q_map) {
|
||||
ql_log(ql_log_fatal, vha, 0x003b,
|
||||
"Unable to allocate memory for request queue ptrs.\n");
|
||||
goto fail_req_map;
|
||||
}
|
||||
|
||||
ha->rsp_q_map = kcalloc(ha->max_rsp_queues, sizeof(struct rsp_que *),
|
||||
GFP_KERNEL);
|
||||
ha->rsp_q_map = kzalloc_objs(struct rsp_que *, ha->max_rsp_queues);
|
||||
if (!ha->rsp_q_map) {
|
||||
ql_log(ql_log_fatal, vha, 0x003c,
|
||||
"Unable to allocate memory for response queue ptrs.\n");
|
||||
@@ -2416,7 +2414,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||
pci_enable_pcie_error_reporting(pdev);
|
||||
#endif
|
||||
|
||||
ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL);
|
||||
ha = kzalloc_obj(struct qla_hw_data);
|
||||
if (!ha) {
|
||||
ql_log_pci(ql_log_fatal, pdev, 0x0009,
|
||||
"Unable to allocate memory for ha.\n");
|
||||
@@ -3260,9 +3258,8 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
|
||||
|
||||
#ifdef CONFIG_SCSI_QLA2XXX_TARGET
|
||||
if (IS_FWI2_CAPABLE(ha)) {
|
||||
ha->tgt_vp_map = kcalloc(MAX_MULTI_ID_FABRIC,
|
||||
sizeof(struct qla_tgt_vp_map),
|
||||
GFP_KERNEL);
|
||||
ha->tgt_vp_map = kzalloc_objs(struct qla_tgt_vp_map,
|
||||
MAX_MULTI_ID_FABRIC);
|
||||
if (!ha->tgt_vp_map)
|
||||
goto fail_free_init_cb;
|
||||
|
||||
@@ -3367,7 +3364,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
|
||||
}
|
||||
|
||||
/* Allocate memory for request ring */
|
||||
*req = kzalloc(sizeof(struct req_que), GFP_KERNEL);
|
||||
*req = kzalloc_obj(struct req_que);
|
||||
if (!*req) {
|
||||
ql_log_pci(ql_log_fatal, ha->pdev, 0x0028,
|
||||
"Failed to allocate memory for req.\n");
|
||||
@@ -3383,7 +3380,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
|
||||
goto fail_req_ring;
|
||||
}
|
||||
/* Allocate memory for response ring */
|
||||
*rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL);
|
||||
*rsp = kzalloc_obj(struct rsp_que);
|
||||
if (!*rsp) {
|
||||
ql_log_pci(ql_log_fatal, ha->pdev, 0x002a,
|
||||
"Failed to allocate memory for rsp.\n");
|
||||
@@ -3408,9 +3405,8 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
|
||||
(*rsp)->ring);
|
||||
/* Allocate memory for NVRAM data for vports */
|
||||
if (ha->nvram_npiv_size) {
|
||||
ha->npiv_info = kcalloc(ha->nvram_npiv_size,
|
||||
sizeof(struct qla_npiv_entry),
|
||||
GFP_KERNEL);
|
||||
ha->npiv_info = kzalloc_objs(struct qla_npiv_entry,
|
||||
ha->nvram_npiv_size);
|
||||
if (!ha->npiv_info) {
|
||||
ql_log_pci(ql_log_fatal, ha->pdev, 0x002d,
|
||||
"Failed to allocate memory for npiv_info.\n");
|
||||
@@ -3719,7 +3715,7 @@ qla2x00_alloc_work(struct scsi_qla_host *vha, enum qla_work_type type)
|
||||
if (bail)
|
||||
return NULL;
|
||||
|
||||
e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC);
|
||||
e = kzalloc_obj(struct qla_work_evt, GFP_ATOMIC);
|
||||
if (!e) {
|
||||
QLA_VHA_MARK_NOT_BUSY(vha);
|
||||
return NULL;
|
||||
|
||||
@@ -164,7 +164,7 @@ static int disk_attach(struct scst_device *dev)
|
||||
* Store serial in a disk_dh_priv struct on dh_priv.
|
||||
* Failure is OK.
|
||||
*/
|
||||
struct disk_dh_priv *priv = kzalloc(sizeof(*priv), GFP_KERNEL);
|
||||
struct disk_dh_priv *priv = kzalloc_obj(*priv);
|
||||
|
||||
if (!priv) {
|
||||
PRINT_ERROR("Memory allocation failure for device %s",
|
||||
|
||||
@@ -1215,9 +1215,8 @@ static int dev_user_map_buf(struct scst_user_cmd *ucmd, unsigned long ubuff, int
|
||||
|
||||
ucmd->num_data_pages = num_pg;
|
||||
|
||||
ucmd->data_pages = kmalloc_array(ucmd->num_data_pages,
|
||||
sizeof(*ucmd->data_pages),
|
||||
GFP_KERNEL);
|
||||
ucmd->data_pages = kmalloc_objs(*ucmd->data_pages,
|
||||
ucmd->num_data_pages);
|
||||
if (!ucmd->data_pages) {
|
||||
TRACE(TRACE_OUT_OF_MEM, "Unable to allocate data_pages array (num_data_pages=%d)",
|
||||
ucmd->num_data_pages);
|
||||
@@ -1503,7 +1502,7 @@ static int dev_user_process_reply_ext_copy_remap(struct scst_user_cmd *ucmd,
|
||||
goto out_hw_err_free_buf;
|
||||
}
|
||||
|
||||
left = kmalloc_array(count, sizeof(*left), GFP_KERNEL);
|
||||
left = kmalloc_objs(*left, count);
|
||||
if (unlikely(!left)) {
|
||||
PRINT_ERROR("Unable to alloc leftover remap descriptors (size %zd, count %d)",
|
||||
sizeof(*left) * count, count);
|
||||
@@ -1657,7 +1656,7 @@ static int dev_user_process_ws_reply(struct scst_user_cmd *ucmd,
|
||||
goto out_free_buf;
|
||||
}
|
||||
|
||||
where = kmalloc_array(count, sizeof(*where), GFP_KERNEL);
|
||||
where = kmalloc_objs(*where, count);
|
||||
if (unlikely(!where)) {
|
||||
PRINT_ERROR("Unable to alloc WS descriptors where (size %zd)",
|
||||
sizeof(*where) * count);
|
||||
@@ -2443,7 +2442,7 @@ static long dev_user_ioctl(struct file *file, unsigned int cmd, unsigned long ar
|
||||
struct scst_user_dev_desc *dev_desc;
|
||||
|
||||
TRACE_DBG("REGISTER_DEVICE");
|
||||
dev_desc = kmalloc(sizeof(*dev_desc), GFP_KERNEL);
|
||||
dev_desc = kmalloc_obj(*dev_desc);
|
||||
if (!dev_desc) {
|
||||
res = -ENOMEM;
|
||||
goto out;
|
||||
|
||||
@@ -3061,8 +3061,7 @@ static bool vdisk_alloc_async_bvec(struct scst_cmd *cmd,
|
||||
return true;
|
||||
}
|
||||
|
||||
p->async.bvec = kmalloc_array(n, sizeof(*p->async.bvec),
|
||||
cmd->cmd_gfp_mask);
|
||||
p->async.bvec = kmalloc_objs(*p->async.bvec, n, cmd->cmd_gfp_mask);
|
||||
if (!p->async.bvec) {
|
||||
PRINT_ERROR("Unable to allocate bvec (%d)", n);
|
||||
return false;
|
||||
@@ -3129,7 +3128,7 @@ static void fileio_async_complete(struct kiocb *iocb, long ret
|
||||
scst_set_cmd_error(cmd,
|
||||
SCST_LOAD_SENSE(scst_sense_hardw_error));
|
||||
} else if (cmd->do_verify) {
|
||||
struct scst_verify_work *w = kmalloc(sizeof(*w), GFP_ATOMIC);
|
||||
struct scst_verify_work *w = kmalloc_obj(*w, GFP_ATOMIC);
|
||||
|
||||
cmd->do_verify = false;
|
||||
if (w) {
|
||||
@@ -5070,8 +5069,8 @@ static struct kvec *vdisk_alloc_sync_kvec(struct scst_cmd *cmd,
|
||||
/* It can't be called in atomic context */
|
||||
p->sync.kvec = kvec_segs <= ARRAY_SIZE(p->sync.small_kvec) ?
|
||||
p->sync.small_kvec :
|
||||
kmalloc_array(kvec_segs, sizeof(*p->sync.kvec),
|
||||
cmd->cmd_gfp_mask);
|
||||
kmalloc_objs(*p->sync.kvec, kvec_segs,
|
||||
cmd->cmd_gfp_mask);
|
||||
if (!p->sync.kvec) {
|
||||
PRINT_ERROR("Unable to allocate kvec (%d)", kvec_segs);
|
||||
goto out;
|
||||
@@ -5571,7 +5570,7 @@ static inline void blockio_check_finish(struct scst_blockio_work *blockio_work)
|
||||
cmd = blockio_work->cmd;
|
||||
|
||||
if (unlikely(cmd->do_verify)) {
|
||||
struct scst_verify_work *w = kmalloc(sizeof(*w), GFP_ATOMIC);
|
||||
struct scst_verify_work *w = kmalloc_obj(*w, GFP_ATOMIC);
|
||||
|
||||
cmd->do_verify = false;
|
||||
if (w) {
|
||||
|
||||
@@ -286,7 +286,7 @@ try_retry:
|
||||
|
||||
/* Wait before retry */
|
||||
|
||||
retry = kzalloc(sizeof(*retry), GFP_KERNEL);
|
||||
retry = kzalloc_obj(*retry);
|
||||
if (!retry) {
|
||||
PRINT_ERROR("Unable to allocate retry struct");
|
||||
scst_set_busy(cmd);
|
||||
@@ -817,7 +817,7 @@ static int scst_cm_add_to_internal_cmd_list(struct scst_cmd *cmd, struct scst_cm
|
||||
|
||||
EXTRACHECKS_BUG_ON(ec_cmd == cmd);
|
||||
|
||||
p = kzalloc(sizeof(*p), GFP_KERNEL);
|
||||
p = kzalloc_obj(*p);
|
||||
if (!p) {
|
||||
PRINT_ERROR("Unable to alloc scst_cm_internal_cmd_priv (size %d)",
|
||||
(int)sizeof(*p));
|
||||
@@ -2396,7 +2396,7 @@ static int scst_cm_send_init_inquiry(struct scst_device *dev, unsigned int unpac
|
||||
}
|
||||
|
||||
if (!priv) {
|
||||
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
|
||||
priv = kzalloc_obj(*priv);
|
||||
if (!priv) {
|
||||
PRINT_ERROR("Unable to alloc priv");
|
||||
res = -ENOMEM;
|
||||
@@ -3104,7 +3104,7 @@ static int scst_cm_add_to_descr_list(struct scst_cmd *ec_cmd, struct scst_tgt_de
|
||||
}
|
||||
}
|
||||
|
||||
e = kzalloc(sizeof(*e), GFP_KERNEL);
|
||||
e = kzalloc_obj(*e);
|
||||
if (!e) {
|
||||
PRINT_ERROR("Unable to allocate scst_cm_dev_entry (size %d)",
|
||||
(int)sizeof(*e));
|
||||
@@ -3461,7 +3461,7 @@ int scst_cm_parse_descriptors(struct scst_cmd *ec_cmd)
|
||||
|
||||
TRACE_DBG("tgt_cnt %d", tgt_cnt);
|
||||
|
||||
tgt_descrs = kcalloc(tgt_cnt, sizeof(*tgt_descrs), GFP_KERNEL);
|
||||
tgt_descrs = kzalloc_objs(*tgt_descrs, tgt_cnt);
|
||||
if (!tgt_descrs) {
|
||||
TRACE(TRACE_OUT_OF_MEM, "Unable to allocate tgt_descrs (count %d, size %zd)",
|
||||
tgt_cnt, sizeof(*tgt_descrs) * tgt_cnt);
|
||||
|
||||
+2
-2
@@ -1501,7 +1501,7 @@ static int scst_pr_dlm_init(struct scst_device *dev, const char *cl_dev_id)
|
||||
dev_registrants_list_entry)
|
||||
scst_dlm_pr_init_reg(dev, reg);
|
||||
|
||||
pr_dlm = kzalloc(sizeof(*dev->pr_dlm), GFP_KERNEL);
|
||||
pr_dlm = kzalloc_obj(*dev->pr_dlm);
|
||||
if (!pr_dlm)
|
||||
goto out;
|
||||
dev->pr_dlm = pr_dlm;
|
||||
@@ -1618,7 +1618,7 @@ static struct scst_dlm_rem_ua *scst_dlm_alloc_rem_ua(void)
|
||||
{
|
||||
struct scst_dlm_rem_ua *ua = NULL;
|
||||
|
||||
ua = kzalloc(sizeof(struct scst_dlm_rem_ua), GFP_KERNEL);
|
||||
ua = kzalloc_obj(struct scst_dlm_rem_ua);
|
||||
if (ua == NULL) {
|
||||
PRINT_ERROR("Unable to allocate unit attention");
|
||||
goto out;
|
||||
|
||||
@@ -874,7 +874,7 @@ static int scst_event_create_priv(struct file *file)
|
||||
goto out;
|
||||
}
|
||||
|
||||
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
|
||||
priv = kzalloc_obj(*priv);
|
||||
if (!priv) {
|
||||
PRINT_ERROR("Unable to allocate priv (size %zd)",
|
||||
sizeof(*priv));
|
||||
|
||||
+9
-10
@@ -4834,8 +4834,7 @@ int scst_acg_repl_lun(struct scst_acg *acg, struct kobject *parent,
|
||||
mutex_unlock(&scst_mutex);
|
||||
|
||||
if (acg_dev && READ_ONCE(scst_async_lun_replace)) {
|
||||
struct scst_async_repl_work *w =
|
||||
kzalloc(sizeof(*w), GFP_KERNEL);
|
||||
struct scst_async_repl_work *w = kzalloc_obj(*w);
|
||||
if (w) {
|
||||
INIT_WORK(&w->work, scst_async_repl_work_fn);
|
||||
INIT_LIST_HEAD(&w->tgt_dev_list);
|
||||
@@ -4867,7 +4866,7 @@ int scst_alloc_add_acg(struct scst_tgt *tgt, const char *acg_name,
|
||||
|
||||
lockdep_assert_held(&scst_mutex);
|
||||
|
||||
acg = kzalloc(sizeof(*acg), GFP_KERNEL);
|
||||
acg = kzalloc_obj(*acg);
|
||||
if (acg == NULL) {
|
||||
PRINT_ERROR("%s", "Allocation of acg failed");
|
||||
res = -ENOMEM;
|
||||
@@ -5034,7 +5033,7 @@ static void scst_release_acg(struct kref *kref)
|
||||
struct scst_acg_release_work *release_work;
|
||||
bool rc;
|
||||
|
||||
release_work = kmalloc(sizeof(*release_work), GFP_KERNEL | __GFP_NOFAIL);
|
||||
release_work = kmalloc_obj(*release_work, GFP_KERNEL | __GFP_NOFAIL);
|
||||
if (WARN_ON_ONCE(!release_work)) {
|
||||
scst_free_acg(acg);
|
||||
return;
|
||||
@@ -5822,7 +5821,7 @@ int scst_acg_add_acn(struct scst_acg *acg, const char *name)
|
||||
}
|
||||
}
|
||||
|
||||
acn = kzalloc(sizeof(*acn), GFP_KERNEL);
|
||||
acn = kzalloc_obj(*acn);
|
||||
if (acn == NULL) {
|
||||
PRINT_ERROR("%s", "Unable to allocate scst_acn");
|
||||
res = -ENOMEM;
|
||||
@@ -6033,7 +6032,7 @@ int scst_prepare_request_sense(struct scst_cmd *orig_cmd)
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
|
||||
priv = kzalloc_obj(*priv);
|
||||
if (!priv)
|
||||
goto out;
|
||||
|
||||
@@ -6736,7 +6735,7 @@ static int scst_ws_sg_init(struct scatterlist **ws_sg, int ws_sg_cnt,
|
||||
struct scatterlist *sg;
|
||||
int i;
|
||||
|
||||
*ws_sg = kmalloc_array(ws_sg_cnt, sizeof(**ws_sg), GFP_KERNEL);
|
||||
*ws_sg = kmalloc_objs(**ws_sg, ws_sg_cnt);
|
||||
if (*ws_sg == NULL) {
|
||||
PRINT_ERROR("Unable to alloc sg for %d entries", ws_sg_cnt);
|
||||
return -ENOMEM;
|
||||
@@ -7186,7 +7185,7 @@ enum scst_exec_res scst_cmp_wr_local(struct scst_cmd *cmd)
|
||||
}
|
||||
|
||||
/* ToDo: HWALIGN'ed kmem_cache */
|
||||
cwrp = kzalloc(sizeof(*cwrp), GFP_KERNEL);
|
||||
cwrp = kzalloc_obj(*cwrp);
|
||||
if (cwrp == NULL) {
|
||||
PRINT_ERROR("Unable to allocate cwr_priv (size %zd, cmd %p)",
|
||||
sizeof(*cwrp), cmd);
|
||||
@@ -8245,7 +8244,7 @@ static struct blk_kern_sg_work *blk_copy_kern_sg(struct request_queue *q,
|
||||
struct blk_kern_sg_work *bw;
|
||||
|
||||
res = -ENOMEM;
|
||||
bw = kzalloc(sizeof(*bw), gfp_mask);
|
||||
bw = kzalloc_obj(*bw, gfp_mask);
|
||||
if (bw == NULL)
|
||||
goto err;
|
||||
|
||||
@@ -14673,7 +14672,7 @@ static int scst_parse_unmap_descriptors(struct scst_cmd *cmd)
|
||||
if (cnt == 0)
|
||||
goto out_put;
|
||||
|
||||
pd = kcalloc(cnt, sizeof(*pd), GFP_KERNEL);
|
||||
pd = kzalloc_objs(*pd, cnt);
|
||||
if (pd == NULL) {
|
||||
PRINT_ERROR("Unable to kmalloc UNMAP %d descriptors", cnt+1);
|
||||
scst_set_busy(cmd);
|
||||
|
||||
+2
-2
@@ -1225,7 +1225,7 @@ struct scatterlist *scst_alloc_sg(int size, gfp_t gfp_mask, int *count)
|
||||
}
|
||||
}
|
||||
|
||||
res = kmalloc_array(pages, sizeof(*res), gfp_mask);
|
||||
res = kmalloc_objs(*res, pages, gfp_mask);
|
||||
if (!res) {
|
||||
TRACE(TRACE_OUT_OF_MEM,
|
||||
"Unable to allocate sg for %d pages", pages);
|
||||
@@ -2090,7 +2090,7 @@ int scst_add_sgv_kobj(struct kobject *parent, const char *name)
|
||||
|
||||
WARN_ON(scst_sgv_kobj);
|
||||
res = -ENOMEM;
|
||||
scst_sgv_kobj = kzalloc(sizeof(*scst_sgv_kobj), GFP_KERNEL);
|
||||
scst_sgv_kobj = kzalloc_obj(*scst_sgv_kobj);
|
||||
if (!scst_sgv_kobj)
|
||||
goto out;
|
||||
res = kobject_init_and_add(scst_sgv_kobj, &sgv_ktype, parent, "%s", name);
|
||||
|
||||
@@ -418,7 +418,7 @@ struct scst_dev_registrant *scst_pr_add_registrant(struct scst_device *dev,
|
||||
goto out;
|
||||
}
|
||||
|
||||
reg = kzalloc(sizeof(*reg), gfp_flags);
|
||||
reg = kzalloc_obj(*reg, gfp_flags);
|
||||
if (!reg) {
|
||||
PRINT_ERROR("Unable to allocate registration record");
|
||||
goto out;
|
||||
|
||||
@@ -346,7 +346,7 @@ int scst_alloc_sysfs_work(int (*sysfs_work_fn)(struct scst_sysfs_work_item *),
|
||||
|
||||
*res_work = NULL;
|
||||
|
||||
work = kzalloc(sizeof(*work), GFP_KERNEL);
|
||||
work = kzalloc_obj(*work);
|
||||
if (!work) {
|
||||
PRINT_ERROR("Unable to alloc sysfs work (size %zd)",
|
||||
sizeof(*work));
|
||||
@@ -5720,7 +5720,7 @@ int scst_acn_sysfs_create(struct scst_acn *acn)
|
||||
|
||||
acn->acn_attr = NULL;
|
||||
|
||||
attr = kzalloc(sizeof(*attr), GFP_KERNEL);
|
||||
attr = kzalloc_obj(*attr);
|
||||
if (!attr) {
|
||||
PRINT_ERROR("Unable to allocate attributes for initiator '%s'",
|
||||
acn->name);
|
||||
@@ -7793,7 +7793,7 @@ int scst_sysfs_user_add_info(struct scst_sysfs_user_info **out_info)
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
info = kzalloc(sizeof(*info), GFP_KERNEL);
|
||||
info = kzalloc_obj(*info);
|
||||
if (!info) {
|
||||
PRINT_ERROR("Unable to allocate sysfs user info (size %zd)",
|
||||
sizeof(*info));
|
||||
|
||||
+7
-7
@@ -476,7 +476,7 @@ static int scst_tg_accept_transitioning(struct scst_cmd *cmd)
|
||||
|
||||
TRACE_DBG("ALUA transitioning: delaying cmd %p", cmd);
|
||||
|
||||
retry = kzalloc(sizeof(*retry), GFP_KERNEL);
|
||||
retry = kzalloc_obj(*retry);
|
||||
if (!retry) {
|
||||
TRACE_DBG("Unable to allocate ALUA retry struct, failing cmd %p", cmd);
|
||||
scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_alua_transitioning));
|
||||
@@ -658,7 +658,7 @@ int scst_tg_tgt_add(struct scst_target_group *tg, const char *name)
|
||||
BUG_ON(!tg);
|
||||
BUG_ON(!name);
|
||||
res = -ENOMEM;
|
||||
tg_tgt = kzalloc(sizeof(*tg_tgt), GFP_KERNEL);
|
||||
tg_tgt = kzalloc_obj(*tg_tgt);
|
||||
if (!tg_tgt)
|
||||
goto out;
|
||||
tg_tgt->tg = tg;
|
||||
@@ -784,7 +784,7 @@ int scst_tg_add(struct scst_dev_group *dg, const char *name)
|
||||
|
||||
TRACE_ENTRY();
|
||||
res = -ENOMEM;
|
||||
tg = kzalloc(sizeof(*tg), GFP_KERNEL);
|
||||
tg = kzalloc_obj(*tg);
|
||||
if (!tg)
|
||||
goto out;
|
||||
kobject_init(&tg->kobj, &scst_tg_ktype);
|
||||
@@ -1185,7 +1185,7 @@ int scst_dg_dev_add(struct scst_dev_group *dg, const char *name)
|
||||
int res;
|
||||
|
||||
res = -ENOMEM;
|
||||
dgdev = kzalloc(sizeof(*dgdev), GFP_KERNEL);
|
||||
dgdev = kzalloc_obj(*dgdev);
|
||||
if (!dgdev)
|
||||
goto out;
|
||||
|
||||
@@ -1309,7 +1309,7 @@ int scst_dg_add(struct kobject *parent, const char *name)
|
||||
TRACE_ENTRY();
|
||||
|
||||
res = -ENOMEM;
|
||||
dg = kzalloc(sizeof(*dg), GFP_KERNEL);
|
||||
dg = kzalloc_obj(*dg);
|
||||
if (!dg)
|
||||
goto out;
|
||||
kobject_init(&dg->kobj, &scst_dg_ktype);
|
||||
@@ -1776,7 +1776,7 @@ static int scst_emit_stpg_event(struct scst_cmd *cmd, struct scst_dev_group *dg,
|
||||
goto out;
|
||||
}
|
||||
|
||||
wait = kzalloc(sizeof(*wait), GFP_KERNEL);
|
||||
wait = kzalloc_obj(*wait);
|
||||
if (!wait) {
|
||||
PRINT_ERROR("Unable to allocate STPG wait struct (size %zd)",
|
||||
sizeof(*wait));
|
||||
@@ -1889,7 +1889,7 @@ int scst_tg_set_group_info(struct scst_cmd *cmd)
|
||||
|
||||
TRACE_DBG("tpg_desc_count %d", tpg_desc_count);
|
||||
|
||||
osi = kcalloc(tpg_desc_count, sizeof(*osi), GFP_KERNEL);
|
||||
osi = kzalloc_objs(*osi, tpg_desc_count);
|
||||
if (!osi) {
|
||||
res = -ENOMEM;
|
||||
scst_set_busy(cmd);
|
||||
|
||||
@@ -1167,7 +1167,7 @@ static int scst_local_report_aen(struct scst_aen *aen)
|
||||
/*
|
||||
* Allocate a work item and place it on the queue
|
||||
*/
|
||||
work_item = kzalloc(sizeof(*work_item), GFP_KERNEL);
|
||||
work_item = kzalloc_obj(*work_item);
|
||||
if (!work_item) {
|
||||
PRINT_ERROR("Unable to allocate work item to handle AEN!");
|
||||
return -ENOMEM;
|
||||
@@ -1587,7 +1587,7 @@ static int __scst_local_add_adapter(struct scst_local_tgt *tgt, const char *init
|
||||
TRACE_ENTRY();
|
||||
|
||||
/* It's read-mostly, so cache alignment isn't needed */
|
||||
sess = kzalloc(sizeof(*sess), GFP_KERNEL);
|
||||
sess = kzalloc_obj(*sess);
|
||||
if (!sess) {
|
||||
PRINT_ERROR("Unable to alloc scst_lcl_host (size %zu)",
|
||||
sizeof(*sess));
|
||||
@@ -1682,7 +1682,7 @@ static int scst_local_add_target(const char *target_name, struct scst_local_tgt
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
tgt = kzalloc(sizeof(*tgt), GFP_KERNEL);
|
||||
tgt = kzalloc_obj(*tgt);
|
||||
if (!tgt) {
|
||||
PRINT_ERROR("Unable to alloc tgt (size %zu)", sizeof(*tgt));
|
||||
res = -ENOMEM;
|
||||
|
||||
+15
-15
@@ -845,7 +845,7 @@ static struct srpt_ioctx **srpt_alloc_ioctx_ring(struct srpt_device *sdev, int r
|
||||
WARN_ON(ioctx_size != sizeof(struct srpt_recv_ioctx) &&
|
||||
ioctx_size != sizeof(struct srpt_send_ioctx));
|
||||
|
||||
ring = kvmalloc_array(ring_size, sizeof(ring[0]), GFP_KERNEL);
|
||||
ring = kvmalloc_objs(ring[0], ring_size);
|
||||
if (!ring)
|
||||
goto out;
|
||||
for (i = 0; i < ring_size; ++i) {
|
||||
@@ -1142,8 +1142,8 @@ static int srpt_get_desc_tbl(struct srpt_recv_ioctx *recv_ioctx,
|
||||
if (ioctx->n_rbuf == 1) {
|
||||
ioctx->rbufs = &ioctx->single_rbuf;
|
||||
} else {
|
||||
ioctx->rbufs = kmalloc_array(ioctx->n_rbuf,
|
||||
sizeof(*db), GFP_ATOMIC);
|
||||
ioctx->rbufs = kmalloc_objs(*db, ioctx->n_rbuf,
|
||||
GFP_ATOMIC);
|
||||
if (!ioctx->rbufs) {
|
||||
ioctx->n_rbuf = 0;
|
||||
return -ENOMEM;
|
||||
@@ -1212,7 +1212,7 @@ static int srpt_init_ch_qp(struct srpt_rdma_ch *ch, struct ib_qp *qp)
|
||||
|
||||
WARN_ON_ONCE(ch->using_rdma_cm);
|
||||
|
||||
attr = kzalloc(sizeof(*attr), GFP_KERNEL);
|
||||
attr = kzalloc_obj(*attr);
|
||||
if (!attr)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -1249,7 +1249,7 @@ static int srpt_ch_qp_rtr(struct srpt_rdma_ch *ch, struct ib_qp *qp)
|
||||
|
||||
WARN_ON_ONCE(ch->using_rdma_cm);
|
||||
|
||||
attr = kzalloc(sizeof(*attr), GFP_KERNEL);
|
||||
attr = kzalloc_obj(*attr);
|
||||
if (!attr)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -1282,7 +1282,7 @@ static int srpt_ch_qp_rts(struct srpt_rdma_ch *ch, struct ib_qp *qp)
|
||||
|
||||
WARN_ON_ONCE(ch->using_rdma_cm);
|
||||
|
||||
attr = kzalloc(sizeof(*attr), GFP_KERNEL);
|
||||
attr = kzalloc_obj(*attr);
|
||||
if (!attr)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -1309,7 +1309,7 @@ static int srpt_ch_qp_err(struct srpt_rdma_ch *ch)
|
||||
struct ib_qp_attr *attr;
|
||||
int ret;
|
||||
|
||||
attr = kzalloc(sizeof(*attr), GFP_KERNEL);
|
||||
attr = kzalloc_obj(*attr);
|
||||
if (!attr)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -2226,7 +2226,7 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch)
|
||||
EXTRACHECKS_WARN_ON(ch->rq_size < 1);
|
||||
|
||||
ret = -ENOMEM;
|
||||
qp_init = kzalloc(sizeof(*qp_init), GFP_KERNEL);
|
||||
qp_init = kzalloc_obj(*qp_init);
|
||||
if (!qp_init)
|
||||
goto out;
|
||||
|
||||
@@ -2442,7 +2442,7 @@ static struct srpt_nexus *srpt_get_nexus(struct srpt_port *sport,
|
||||
|
||||
if (nexus)
|
||||
break;
|
||||
tmp_nexus = kzalloc(sizeof(*nexus), GFP_KERNEL);
|
||||
tmp_nexus = kzalloc_obj(*nexus);
|
||||
if (!tmp_nexus) {
|
||||
nexus = ERR_PTR(-ENOMEM);
|
||||
break;
|
||||
@@ -2565,9 +2565,9 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev,
|
||||
}
|
||||
|
||||
ret = -ENOMEM;
|
||||
rsp = kzalloc(sizeof(*rsp), GFP_KERNEL);
|
||||
rej = kzalloc(sizeof(*rej), GFP_KERNEL);
|
||||
rep_param = kzalloc(sizeof(*rep_param), GFP_KERNEL);
|
||||
rsp = kzalloc_obj(*rsp);
|
||||
rej = kzalloc_obj(*rej);
|
||||
rep_param = kzalloc_obj(*rep_param);
|
||||
if (!rsp || !rej || !rep_param)
|
||||
goto out;
|
||||
|
||||
@@ -2594,7 +2594,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev,
|
||||
}
|
||||
|
||||
ret = -ENOMEM;
|
||||
ch = kzalloc(sizeof(*ch), GFP_KERNEL);
|
||||
ch = kzalloc_obj(*ch);
|
||||
if (!ch) {
|
||||
rej->reason = cpu_to_be32(SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES);
|
||||
pr_err("rejected SRP_LOGIN_REQ because out of memory.\n");
|
||||
@@ -3794,7 +3794,7 @@ static int srpt_get_initiator_port_transport_id(struct scst_tgt *tgt, struct scs
|
||||
BUILD_BUG_ON(sizeof(*tr_id) != 24);
|
||||
|
||||
res = -ENOMEM;
|
||||
tr_id = kzalloc(sizeof(*tr_id), GFP_KERNEL);
|
||||
tr_id = kzalloc_obj(*tr_id);
|
||||
if (!tr_id)
|
||||
goto out;
|
||||
|
||||
@@ -4264,7 +4264,7 @@ static int srpt_add_one(struct ib_device *device)
|
||||
|
||||
pr_debug("device = %p\n", device);
|
||||
|
||||
sdev = kzalloc(sizeof(*sdev), GFP_KERNEL);
|
||||
sdev = kzalloc_obj(*sdev);
|
||||
if (!sdev) {
|
||||
ret = -ENOMEM;
|
||||
goto err;
|
||||
|
||||
Reference in New Issue
Block a user