From fcbb8e916bb69990e1f2cfc7a0066e3213daa2c5 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Thu, 17 Mar 2022 09:19:39 +0100 Subject: [PATCH] virnetdev: Use VIR_WITH_MUTEX_LOCK_GUARD in virNetDevGenerateName() 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 Reviewed-by: Pavel Hrdina --- src/util/virnetdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 5df48af60c..1c15a475fa 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -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 */