Skip to content

Commit b4194fd

Browse files
gwcornelisj-xiong
authored andcommitted
[v2.1.x] prov/opx: Adding changes to resolve Coverity Scan Defects
-Fix for Coverity Defect 456943 - moving unnecessary null check before dereference -Fix for Coverity Defect 456942 - add harsher case than assert to prevent possible negative array indexing -Fix for Coverity Defect 456941 - moving null check before dereference -Fix for Coverity Defect 456939 - moving null check before first dereference -Fix for Coverity Defect 456938 - adding null check -Fix for Coverity Defect 454699 - add missing free statement to err case Signed-off-by: Garrett Weil <[email protected]> (cherry picked from commit 9e4315f)
1 parent c535e5a commit b4194fd

File tree

5 files changed

+22
-14
lines changed

5 files changed

+22
-14
lines changed

prov/opx/include/rdma/opx/fi_opx_reliability.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,9 @@ struct fi_opx_reliability_flow *fi_opx_reliability_create_rx_flow(struct fi_opx_
767767

768768
if (OFI_UNLIKELY(rbt_rc != RBT_STATUS_OK)) {
769769
void *itr = fi_opx_rbt_find(state->rx_flow_rbtree, (void *) key);
770-
rbtErase(state->rx_flow_rbtree, itr);
770+
if (itr) {
771+
rbtErase(state->rx_flow_rbtree, itr);
772+
}
771773
free(flow);
772774
FI_WARN(fi_opx_global.prov, FI_LOG_EP_DATA,
773775
"Error creating RX Flow: Could not insert flow into rx.flow, rbtInsert() returned %d\n",

prov/opx/src/fi_opx_domain.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ int fi_opx_choose_domain(uint64_t caps, struct fi_domain_attr *domain_attr, stru
197197
domain_attr->mr_mode |= FI_MR_HMEM;
198198
#endif
199199

200-
if (hints->mr_mode & FI_MR_VIRT_ADDR) {
201-
FI_INFO(fi_opx_global.prov, FI_LOG_DOMAIN,
202-
"Application requests FI_MR_VIRT_ADDR, OPX is turning on that mr_mode bit\n");
203-
domain_attr->mr_mode |= FI_MR_VIRT_ADDR;
204-
}
205-
206200
if (hints) {
201+
if (hints->mr_mode & FI_MR_VIRT_ADDR) {
202+
FI_INFO(fi_opx_global.prov, FI_LOG_DOMAIN,
203+
"Application requests FI_MR_VIRT_ADDR, OPX is turning on that mr_mode bit\n");
204+
domain_attr->mr_mode |= FI_MR_VIRT_ADDR;
205+
}
206+
207207
if (hints->domain) {
208208
struct fi_opx_domain *opx_domain =
209209
container_of(hints->domain, struct fi_opx_domain, domain_fid);

prov/opx/src/fi_opx_ep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2273,7 +2273,7 @@ int fi_opx_check_tx_attr(struct fi_tx_attr *tx_attr, uint64_t hinted_caps)
22732273
goto err;
22742274
}
22752275

2276-
if ((tx_attr) && ((tx_attr->caps | hinted_caps) != hinted_caps)) {
2276+
if ((tx_attr->caps | hinted_caps) != hinted_caps) {
22772277
FI_DBG_TRACE(
22782278
fi_opx_global.prov, FI_LOG_EP_DATA,
22792279
"info->tx_attr->caps = 0x%016lx, info->caps = 0x%016lx, (info->tx_attr->caps | info->caps) = 0x%016lx, ((info->tx_attr->caps | info->caps) ^ info->caps) = 0x%016lx\n",

prov/opx/src/fi_opx_sep.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,15 @@ static int fi_opx_rx_ctx(struct fid_ep *sep, int index, struct fi_rx_attr *attr,
358358
if (info.tx_attr) {
359359
free(info.tx_attr);
360360
}
361+
if (info.rx_attr) {
362+
free(info.rx_attr);
363+
}
361364

362365
info.fabric_attr = NULL;
363366
info.domain_attr = NULL;
364367
info.ep_attr = NULL;
365368
info.tx_attr = NULL;
369+
info.rx_attr = NULL;
366370

367371
return -errno;
368372
}

prov/opx/src/opa_proto.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
GPL LICENSE SUMMARY
77
88
Copyright(c) 2015 Intel Corporation.
9-
Copyright(C) 2021-2024 Cornelis Networks.
9+
Copyright(C) 2021-2025 Cornelis Networks.
1010
1111
This program is free software; you can redistribute it and/or modify
1212
it under the terms of version 2 of the GNU General Public License as
@@ -200,6 +200,9 @@ int opx_map_hfi_mem(int fd, struct _hfi_ctrl *ctrl, size_t subctxt_cnt, __u64 *r
200200

201201
/* 10. Map the RHEQ page (JKR only) */
202202
sz = sizeof(uint64_t) * (size_t) cinfo->rcvhdrq_cnt;
203+
if (!rheq) { /* should never happen */
204+
return -1;
205+
}
203206
_HFI_PDBG("ctx %#hx, subctxt_cnt %#lx, rheq %#llX, fd %d, sz %zu/%zu\n", cinfo->ctxt, subctxt_cnt, *rheq, fd,
204207
sz, (size_t) cinfo->rcvhdrq_cnt);
205208
errno = 0;
@@ -357,13 +360,12 @@ int opx_map_hfi_mem(int fd, struct _hfi_ctrl *ctrl, size_t subctxt_cnt, __u64 *r
357360

358361
err_mmap_subctxt_rcvhdrbuf:
359362
/* if we got it here, subctxt_cnt must be != 0 */
360-
HFI_MUNMAP_ERRCHECK(binfo, subctxt_uregbase, arrsz[SUBCTXT_UREGBASE]);
361-
362-
err_mmap_subctxt_rheq:
363-
/* New field, special handling */
364363
if (rheq && *rheq) {
365-
HFI_MUNMAP((void *) *rheq, sizeof(uint64_t) * (size_t) cinfo->rcvhdrq_cnt);
364+
HFI_MUNMAP_ERRCHECK(binfo, subctxt_uregbase, arrsz[SUBCTXT_UREGBASE]);
366365
}
366+
err_mmap_subctxt_rheq:
367+
/* New field, special handling */
368+
HFI_MUNMAP((void *) *rheq, sizeof(uint64_t) * (size_t) cinfo->rcvhdrq_cnt);
367369

368370
err_mmap_subctxt_uregbase:
369371
HFI_MUNMAP_ERRCHECK(binfo, status_bufbase, arrsz[STATUS_BUFBASE]);

0 commit comments

Comments
 (0)