[ovs-dev] [PATCH] dpif-netdev: Initialize new rxqs in port_reconfigure().

Ben Pfaff blp at ovn.org
Thu Oct 26 23:49:01 UTC 2017


valgrind reported use of uninitialized data in port_reconfigure(), which
was due to xrealloc() not initializing the newly added data, combined with
dp_netdev_rxq_set_intrvl_cycles() reading 'intrvl_idx' from the added data.
This avoids the warning.

Signed-off-by: Ben Pfaff <blp at ovn.org>
---
 lib/dpif-netdev.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index d5eb8305c8a2..1418175bdfef 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -3285,9 +3285,14 @@ port_reconfigure(struct dp_netdev_port *port)
     port->txq_used = xcalloc(netdev_n_txq(netdev), sizeof *port->txq_used);
 
     for (i = 0; i < netdev_n_rxq(netdev); i++) {
+        bool new_queue = i >= last_nrxq;
+        if (new_queue) {
+            memset(&port->rxqs[i], 0, sizeof port->rxqs[i]);
+        }
+
         port->rxqs[i].port = port;
-        if (i >= last_nrxq) {
-            /* Only reset cycle stats for new queues */
+
+        if (new_queue) {
             dp_netdev_rxq_set_cycles(&port->rxqs[i], RXQ_CYCLES_PROC_CURR, 0);
             dp_netdev_rxq_set_cycles(&port->rxqs[i], RXQ_CYCLES_PROC_HIST, 0);
             for (unsigned j = 0; j < PMD_RXQ_INTERVAL_MAX; j++) {
-- 
2.10.2



More information about the dev mailing list