Skip to content

Commit

Permalink
net/tap: fix queues fd check before close
Browse files Browse the repository at this point in the history
[ upstream commit 13b698d ]

The fd is possibly a negative value while it is passed as an
argument to function "close". Fix the check to the fd.

Fixes: ed8132e ("net/tap: move fds of queues to be in process private")

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  • Loading branch information
wyjwang authored and kevintraynor committed May 27, 2020
1 parent faf078d commit b60cfb0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions drivers/net/tap/rte_eth_tap.c
Expand Up @@ -1076,7 +1076,7 @@ tap_rx_queue_release(void *queue)
if (!rxq)
return;
process_private = rte_eth_devices[rxq->in_port].process_private;
if (process_private->rxq_fds[rxq->queue_id] > 0) {
if (process_private->rxq_fds[rxq->queue_id] != -1) {
close(process_private->rxq_fds[rxq->queue_id]);
process_private->rxq_fds[rxq->queue_id] = -1;
tap_rxq_pool_free(rxq->pool);
Expand All @@ -1096,7 +1096,7 @@ tap_tx_queue_release(void *queue)
return;
process_private = rte_eth_devices[txq->out_port].process_private;

if (process_private->txq_fds[txq->queue_id] > 0) {
if (process_private->txq_fds[txq->queue_id] != -1) {
close(process_private->txq_fds[txq->queue_id]);
process_private->txq_fds[txq->queue_id] = -1;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/tap/tap_intr.c
Expand Up @@ -71,7 +71,7 @@ tap_rx_intr_vec_install(struct rte_eth_dev *dev)
struct rx_queue *rxq = pmd->dev->data->rx_queues[i];

/* Skip queues that cannot request interrupts. */
if (!rxq || process_private->rxq_fds[i] <= 0) {
if (!rxq || process_private->rxq_fds[i] == -1) {
/* Use invalid intr_vec[] index to disable entry. */
intr_handle->intr_vec[i] =
RTE_INTR_VEC_RXTX_OFFSET +
Expand Down

0 comments on commit b60cfb0

Please sign in to comment.