From: Ankur Dwivedi Date: Fri, 17 Apr 2020 15:41:55 +0000 (+0530) Subject: examples/ipsec-secgw: check event adapter errors X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=f5ad5016869b06aa6e03dc1e38dcf8e4d1c733bf;p=dpdk.git examples/ipsec-secgw: check event adapter errors The return values of functions are checked before proceeding further. Coverity issue: 355670, 355671, 355672, 355673 Fixes: 1d89ccf32301 ("examples/ipsec-secgw: support event Tx adapter") Signed-off-by: Ankur Dwivedi Acked-by: Anoob Joseph Acked-by: Akhil Goyal --- diff --git a/examples/ipsec-secgw/event_helper.c b/examples/ipsec-secgw/event_helper.c index 076f1f292d..865dc911b8 100644 --- a/examples/ipsec-secgw/event_helper.c +++ b/examples/ipsec-secgw/event_helper.c @@ -100,12 +100,15 @@ static inline bool eh_dev_has_rx_internal_port(uint8_t eventdev_id) { bool flag = true; - int j; + int j, ret; RTE_ETH_FOREACH_DEV(j) { uint32_t caps = 0; - rte_event_eth_rx_adapter_caps_get(eventdev_id, j, &caps); + ret = rte_event_eth_rx_adapter_caps_get(eventdev_id, j, &caps); + if (ret < 0) + return false; + if (!(caps & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT)) flag = false; } @@ -116,12 +119,15 @@ static inline bool eh_dev_has_tx_internal_port(uint8_t eventdev_id) { bool flag = true; - int j; + int j, ret; RTE_ETH_FOREACH_DEV(j) { uint32_t caps = 0; - rte_event_eth_tx_adapter_caps_get(eventdev_id, j, &caps); + ret = rte_event_eth_tx_adapter_caps_get(eventdev_id, j, &caps); + if (ret < 0) + return false; + if (!(caps & RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT)) flag = false; } @@ -323,6 +329,7 @@ eh_set_default_conf_rx_adapter(struct eventmode_conf *em_conf) int nb_eth_dev; int adapter_id; int conn_id; + int ret; int i; /* Create one adapter with eth queues mapped to event queue(s) */ @@ -385,7 +392,12 @@ eh_set_default_conf_rx_adapter(struct eventmode_conf *em_conf) conn->ethdev_rx_qid = -1; /* Get Rx adapter capabilities */ - rte_event_eth_rx_adapter_caps_get(eventdev_id, i, &caps); + ret = rte_event_eth_rx_adapter_caps_get(eventdev_id, i, &caps); + if (ret < 0) { + EH_LOG_ERR("Failed to get event device %d eth rx adapter" + " capabilities for port %d", eventdev_id, i); + return ret; + } if (!(caps & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT)) rx_internal_port = false; @@ -420,6 +432,7 @@ eh_set_default_conf_tx_adapter(struct eventmode_conf *em_conf) int adapter_id; int nb_eth_dev; int conn_id; + int ret; int i; /* @@ -479,7 +492,12 @@ eh_set_default_conf_tx_adapter(struct eventmode_conf *em_conf) conn->ethdev_tx_qid = -1; /* Get Tx adapter capabilities */ - rte_event_eth_tx_adapter_caps_get(eventdev_id, i, &caps); + ret = rte_event_eth_tx_adapter_caps_get(eventdev_id, i, &caps); + if (ret < 0) { + EH_LOG_ERR("Failed to get event device %d eth tx adapter" + " capabilities for port %d", eventdev_id, i); + return ret; + } if (!(caps & RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT)) tx_internal_port = false;