summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2022-04-05 10:46:39 +0000
committerBeno�t Ganne <bganne@cisco.com>2022-04-05 11:31:05 +0000
commit3ce1d14e1fc005315bccfa6f9467487166644538 (patch)
treeb0a3744b648868b88c09a7709820cb6a43c28735 /src/vnet
parenta117c01c2b4d6903154edbe52abba497ef2dd2b4 (diff)
devices: fix the coverity warnings for af-packet v3
Type: fix Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com> Change-Id: Ie647fb280831af23925c4b5f659f1dade6d37eff
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/devices/af_packet/af_packet.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/vnet/devices/af_packet/af_packet.c b/src/vnet/devices/af_packet/af_packet.c
index ac6fc05a627..b84f5cd280e 100644
--- a/src/vnet/devices/af_packet/af_packet.c
+++ b/src/vnet/devices/af_packet/af_packet.c
@@ -401,15 +401,18 @@ af_packet_queue_init (vlib_main_t *vm, af_packet_if_t *apif,
tx_req = tx_queue->tx_req;
}
- ret = create_packet_v3_sock (apif->host_if_index, rx_req, tx_req, &fd, &ring,
- &hdrlen, &is_cksum_gso_enabled,
- apif->dev_instance, is_fanout);
+ if (rx_queue || tx_queue)
+ {
+ ret = create_packet_v3_sock (apif->host_if_index, rx_req, tx_req, &fd,
+ &ring, &hdrlen, &is_cksum_gso_enabled,
+ apif->dev_instance, is_fanout);
- if (ret != 0)
- goto error;
+ if (ret != 0)
+ goto error;
- vec_add1 (apif->rings, ring);
- ring_addr = ring.ring_start_addr;
+ vec_add1 (apif->rings, ring);
+ ring_addr = ring.ring_start_addr;
+ }
if (rx_queue)
{
@@ -452,8 +455,10 @@ af_packet_queue_init (vlib_main_t *vm, af_packet_if_t *apif,
return 0;
error:
vlib_log_err (apm->log_class, "Failed to set queue %u error", queue_id);
- vec_free (rx_queue->rx_req);
- vec_free (tx_queue->tx_req);
+ if (rx_queue)
+ vec_free (rx_queue->rx_req);
+ if (tx_queue)
+ vec_free (tx_queue->tx_req);
return ret;
}