[ovs-dev] netdev-linux: dev_stats should be initialized before used

Message ID 1509180037-13812-1-git-send-email-zhongbaisong@huawei.com
State New
Headers show
Series
  • [ovs-dev] netdev-linux: dev_stats should be initialized before used
Related show

Commit Message

zhongbaisong Oct. 28, 2017, 8:40 a.m.
From: zhongbasiong <zhongbaisong@huawei.com>

struct netdev_stats dev_stats was used without initialized.
As result, the output of 'ovs-vsctl list interface' has some random
values.

Signed-off-by: zhongbasiong <zhongbaisong@huawei.com>
---
 lib/netdev-linux.c | 2 ++
 1 file changed, 2 insertions(+)

Patch

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 2ff3e2b..09f174b 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -1726,6 +1726,7 @@  netdev_linux_get_stats(const struct netdev *netdev_,
     int error;
 
     ovs_mutex_lock(&netdev->mutex);
+    memset(&dev_stats, 0, sizeof(struct netdev_stats));
     get_stats_via_vport(netdev_, stats);
     error = get_stats_via_netlink(netdev_, &dev_stats);
     if (error) {
@@ -1777,6 +1778,7 @@  netdev_tap_get_stats(const struct netdev *netdev_, struct netdev_stats *stats)
     int error;
 
     ovs_mutex_lock(&netdev->mutex);
+    memset(&dev_stats, 0, sizeof(struct netdev_stats));
     get_stats_via_vport(netdev_, stats);
     error = get_stats_via_netlink(netdev_, &dev_stats);
     if (error) {