[ovs-dev] [PATCH] netdev-dummy: Lock mutex when retrieving custom stats.

Ben Pfaff blp at ovn.org
Wed Jan 10 23:47:20 UTC 2018


Found by Clang.

CC: Michal Weglicki <michalx.weglicki at intel.com>
Fixes: 971f4b394c6e ("netdev: Custom statistics.")
Signed-off-by: Ben Pfaff <blp at ovn.org>
---
Somehow I didn't notice this before I applied the previous patch.  Oops,
sorry.

 lib/netdev-dummy.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c
index 57da19c48fcb..4246af3b9c86 100644
--- a/lib/netdev-dummy.c
+++ b/lib/netdev-dummy.c
@@ -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;
 }
-- 
2.10.2



More information about the dev mailing list