Hi Ben, 

You are right, I totally forgot about this mutex. 

- Michal. 

> -----Original Message-----
> From: Ben Pfaff [mailto:[email protected]]
> Sent: Thursday, January 11, 2018 12:47 AM
> To: [email protected]
> Cc: Ben Pfaff <[email protected]>; Weglicki, MichalX <[email protected]>
> Subject: [PATCH] netdev-dummy: Lock mutex when retrieving custom stats.
> 
> Found by Clang.
> 
> CC: Michal Weglicki <[email protected]>
> Fixes: 971f4b394c6e ("netdev: Custom statistics.")
> Signed-off-by: Ben Pfaff <[email protected]>
> ---
> 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

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to