[libvirt] [PATCH 2/4] virchrdev: Don't leak mutex if virChrdevAlloc() fails

Michal Privoznik mprivozn at redhat.com
Wed Jan 8 08:18:30 UTC 2020


This is only a theoretical leak, but in virChrdevAlloc() we
initialize a mutex and if creating a hash table fails,
then virChrdevFree() is called which because of incorrect check
doesn't deinit the mutex.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/conf/virchrdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c
index 7657c41ece..6e659a3783 100644
--- a/src/conf/virchrdev.c
+++ b/src/conf/virchrdev.c
@@ -311,7 +311,7 @@ static int virChrdevFreeClearCallbacks(void *payload,
  */
 void virChrdevFree(virChrdevsPtr devs)
 {
-    if (!devs || !devs->hash)
+    if (!devs)
         return;
 
     virMutexLock(&devs->lock);
-- 
2.24.1




More information about the libvir-list mailing list