Skip to content

Commit

Permalink
netdev-dummy: Lock mutex when retrieving custom stats.
Browse files Browse the repository at this point in the history
Found by Clang.

CC: Michal Weglicki <[email protected]>
Fixes: 971f4b3 ("netdev: Custom statistics.")
Signed-off-by: Ben Pfaff <[email protected]>
Reviewed-by: Yifeng Sun <[email protected]>
  • Loading branch information
blp committed Jan 11, 2018
1 parent 971f4b3 commit ae9f2ce
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/netdev-dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit ae9f2ce

Please sign in to comment.