From 1dfaa0b498d2c465557551ac7d97c8b469547447 Mon Sep 17 00:00:00 2001 From: Yossi Itigin Date: Sun, 18 Sep 2016 19:10:42 +0300 Subject: [PATCH] UCT/DC: Fix out-of-bounds array access, found by coverity. --- src/uct/ib/dc/base/dc_ep.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/uct/ib/dc/base/dc_ep.c b/src/uct/ib/dc/base/dc_ep.c index 34802484dd0..7f1c82d940e 100644 --- a/src/uct/ib/dc/base/dc_ep.c +++ b/src/uct/ib/dc/base/dc_ep.c @@ -50,11 +50,16 @@ ucs_status_t uct_dc_ep_pending_add(uct_ep_h tl_ep, uct_pending_req_t *r) * - dci is either assigned or can be assigned * - dci has resources */ - if (uct_rc_iface_has_tx_resources(&iface->super) && - ((ep->dci != UCT_DC_EP_NO_DCI) || uct_dc_iface_dci_can_alloc(iface)) && - uct_dc_iface_dci_ep_can_send(ep)) - { - return UCS_ERR_BUSY; + if (uct_rc_iface_has_tx_resources(&iface->super)) { + if (ep->dci == UCT_DC_EP_NO_DCI) { + if (uct_dc_iface_dci_can_alloc(iface)) { + return UCS_ERR_BUSY; + } + } else { + if (uct_dc_iface_dci_ep_can_send(ep)) { + return UCS_ERR_BUSY; + } + } } UCS_STATIC_ASSERT(sizeof(ucs_arbiter_elem_t) <= UCT_PENDING_REQ_PRIV_LEN);