devices: fix the coverity warnings for af-packet v3
Type: fix
@@ -401,8 +401,10 @@ 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,
+ 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)
@@ -410,6 +412,7 @@ af_packet_queue_init (vlib_main_t *vm, af_packet_if_t *apif,
vec_add1 (apif->rings, ring);
ring_addr = ring.ring_start_addr;
+ }
if (rx_queue)
{
@@ -452,7 +455,9 @@ 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);
+ if (rx_queue)
vec_free (rx_queue->rx_req);
+ if (tx_queue)
vec_free (tx_queue->tx_req);
return ret;
}
