virchrdev: Don't leak mutex if virChrdevAlloc() fails

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@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Michal Privoznik 2020-01-08 09:18:30 +01:00
parent aab3779994
commit 15b821122e

View File

@ -311,7 +311,7 @@ static int virChrdevFreeClearCallbacks(void *payload,
*/ */
void virChrdevFree(virChrdevsPtr devs) void virChrdevFree(virChrdevsPtr devs)
{ {
if (!devs || !devs->hash) if (!devs)
return; return;
virMutexLock(&devs->lock); virMutexLock(&devs->lock);