aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDotan Barak <dotanb@dev.mellanox.co.il>2007-10-10 11:25:18 +0200
committerRoland Dreier <rolandd@cisco.com>2008-02-15 13:18:41 -0800
commit9eb2125b2027358f2516980d85b82a4fb23d3da3 (patch)
tree9e9471ee57e9862d11da022068e8d218c710e6d6
parentcfed37c1804b7287aa062f26631314a534038be0 (diff)
downloadlibibverbs-9eb2125b2027358f2516980d85b82a4fb23d3da3.tar.gz
Fix several valgrind false positives
Fix several issues that were reported by valgrind: * Initialize reserved attributes of command structures * Fix the pointer and size when calling VALGRIND_MAKE_MEM_DEFINED in ibv_cmd_reg_mr() and ibv_cmd_create_cq_v2(): if we have struct xxx_resp *resp and resp_size, we need to do VALGRIND_MAKE_MEM_DEFINED(resp, resp_size) rather than the getting the paramters wrong as in VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp) VALGRIND_MAKE_MEM_DEFINED(resp, sizeof resp_size); * Call VALGRIND_MAKE_MEM_DEFINED for buffers that are filled by the kernel in ibv_cmd_query_srq(), ibv_cmd_destroy_srq() and ibv_cmd_query_qp(). Signed-off-by: Dotan Barak <dotanb@dev.mellanox.co.il> Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r--src/cmd.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/cmd.c b/src/cmd.c
index 31b592e..9db8aa6 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -248,7 +248,7 @@ int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size)
return errno;
- VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+ VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
mr->handle = resp->mr_handle;
mr->lkey = resp->lkey;
@@ -291,7 +291,7 @@ static int ibv_cmd_create_cq_v2(struct ibv_context *context, int cqe,
if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
return errno;
- VALGRIND_MAKE_MEM_DEFINED(resp, sizeof resp_size);
+ VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
cq->handle = resp->cq_handle;
cq->cqe = resp->cqe;
@@ -432,6 +432,7 @@ int ibv_cmd_destroy_cq(struct ibv_cq *cq)
IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_CQ, &resp, sizeof resp);
cmd.cq_handle = cq->handle;
+ cmd.reserved = 0;
if (write(cq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
return errno;
@@ -539,10 +540,13 @@ int ibv_cmd_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr,
IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_SRQ, &resp, sizeof resp);
cmd->srq_handle = srq->handle;
+ cmd->reserved = 0;
if (write(srq->context->cmd_fd, cmd, cmd_size) != cmd_size)
return errno;
+ VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
srq_attr->max_wr = resp.max_wr;
srq_attr->max_sge = resp.max_sge;
srq_attr->srq_limit = resp.srq_limit;
@@ -573,10 +577,13 @@ int ibv_cmd_destroy_srq(struct ibv_srq *srq)
IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_SRQ, &resp, sizeof resp);
cmd.srq_handle = srq->handle;
+ cmd.reserved = 0;
if (write(srq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
return errno;
+ VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
pthread_mutex_lock(&srq->mutex);
while (srq->events_completed != resp.events_reported)
pthread_cond_wait(&srq->cond, &srq->mutex);
@@ -657,6 +664,8 @@ int ibv_cmd_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
if (write(qp->context->cmd_fd, cmd, cmd_size) != cmd_size)
return errno;
+ VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
attr->qkey = resp.qkey;
attr->rq_psn = resp.rq_psn;
attr->sq_psn = resp.sq_psn;
@@ -1067,6 +1076,7 @@ int ibv_cmd_destroy_qp(struct ibv_qp *qp)
IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_QP, &resp, sizeof resp);
cmd.qp_handle = qp->handle;
+ cmd.reserved = 0;
if (write(qp->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
return errno;
@@ -1089,6 +1099,7 @@ int ibv_cmd_attach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid)
memcpy(cmd.gid, gid->raw, sizeof cmd.gid);
cmd.qp_handle = qp->handle;
cmd.mlid = lid;
+ cmd.reserved = 0;
if (write(qp->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
return errno;
@@ -1104,6 +1115,7 @@ int ibv_cmd_detach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid)
memcpy(cmd.gid, gid->raw, sizeof cmd.gid);
cmd.qp_handle = qp->handle;
cmd.mlid = lid;
+ cmd.reserved = 0;
if (write(qp->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
return errno;