]> git.proxmox.com Git - ovs.git/commitdiff
netdev-dummy: Lock mutex when retrieving custom stats.
authorBen Pfaff <blp@ovn.org>
Wed, 10 Jan 2018 23:47:20 +0000 (15:47 -0800)
committerBen Pfaff <blp@ovn.org>
Thu, 11 Jan 2018 00:07:53 +0000 (16:07 -0800)
Found by Clang.

CC: Michal Weglicki <michalx.weglicki@intel.com>
Fixes: 971f4b394c6e ("netdev: Custom statistics.")
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
lib/netdev-dummy.c

index 57da19c48fcb2b6fc44b08716b93fa524106a84c..4246af3b9c86fb6214ccbf49376d54dd1f723b47 100644 (file)
@@ -1239,12 +1239,14 @@ netdev_dummy_get_custom_stats(const struct netdev *netdev,
             (struct netdev_custom_counter *) xcalloc(C_STATS_SIZE,
                     sizeof(struct netdev_custom_counter));
 
+    ovs_mutex_lock(&dev->mutex);
     for (i = 0 ; i < C_STATS_SIZE ; i++) {
         custom_stats->counters[i].value = dev->custom_stats[i].value;
         ovs_strlcpy(custom_stats->counters[i].name,
                     dev->custom_stats[i].name,
                     NETDEV_CUSTOM_STATS_NAME_SIZE);
     }
+    ovs_mutex_unlock(&dev->mutex);
 
     return 0;
 }