]> xenbits.xensource.com Git - libvirt.git/commitdiff
virnetdev: Use VIR_WITH_MUTEX_LOCK_GUARD in virNetDevGenerateName()
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 17 Mar 2022 08:19:39 +0000 (09:19 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 17 Mar 2022 08:45:38 +0000 (09:45 +0100)
The virNetDevGenerateName() function uses a global array of
virNetDevGenName structs to find next unused name for network
device. This obviously needs some locking and in fact each member
of the array has its own lock. However, these members are not
virObjects, they are just plain structs, therefore
VIR_WITH_MUTEX_LOCK_GUARD() must be used instead of
VIR_WITH_OBJECT_LOCK_GUARD() to lock individual mutexes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/util/virnetdev.c

index 5df48af60c86451f985f0a4acce735e667348905..1c15a475fad2011e4ccebe7489d0a00823521742 100644 (file)
@@ -3616,7 +3616,7 @@ virNetDevGenerateName(char **ifname, virNetDevGenNameType type)
         g_autofree char *try = NULL;
         int id = 0;
 
-        VIR_WITH_OBJECT_LOCK_GUARD(&virNetDevGenNames[type].mutex) {
+        VIR_WITH_MUTEX_LOCK_GUARD(&virNetDevGenNames[type].mutex) {
             id = ++virNetDevGenNames[type].lastID;
 
             /* reset before overflow */