@@ -984,24 +984,19 @@ static int srpt_get_desc_tbl(struct srpt_send_ioctx *ioctx,
*/
static int srpt_init_ch_qp(struct srpt_rdma_ch *ch, struct ib_qp *qp)
{
- struct ib_qp_attr *attr;
+ struct ib_qp_attr attr = { 0 };
int ret;
- attr = kzalloc(sizeof(*attr), GFP_KERNEL);
- if (!attr)
- return -ENOMEM;
-
- attr->qp_state = IB_QPS_INIT;
- attr->qp_access_flags = IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_READ |
+ attr.qp_state = IB_QPS_INIT;
+ attr.qp_access_flags = IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_READ |
IB_ACCESS_REMOTE_WRITE;
- attr->port_num = ch->sport->port;
- attr->pkey_index = 0;
+ attr.port_num = ch->sport->port;
+ attr.pkey_index = 0;
- ret = ib_modify_qp(qp, attr,
+ ret = ib_modify_qp(qp, &attr,
IB_QP_STATE | IB_QP_ACCESS_FLAGS | IB_QP_PORT |
IB_QP_PKEY_INDEX);
- kfree(attr);
return ret;
}
No reason to use kzalloc that may increase memory fragmentation. This also simplifies the code in means of memory alloc/free in initialization flow. Signed-off-by: Max Gurtovoy <maxg@mellanox.com> --- drivers/infiniband/ulp/srpt/ib_srpt.c | 17 ++++++----------- 1 files changed, 6 insertions(+), 11 deletions(-)