Comment 27 for bug 1822096

I had the simple suggestion of instead using this:
--- a/src/conf/virchrdev.c
+++ b/src/conf/virchrdev.c
@@ -310,8 +310,8 @@ void virChrdevFree(virChrdevsPtr devs)
     if (!devs || !devs->hash)

- virMutexLock(&devs->lock);
     virHashForEach(devs->hash, virChrdevFreeClearCallbacks, NULL);
+ virMutexLock(&devs->lock);

But then this breaks as well:
 if (fdst->icbFreeOpaque)
 (Segfaults as fdst became 0 which was formerly indirectly blocked by the devs->lock being held.

Actually if there is no FDST anymore after the lock is acquired we can just do an early exit.

--- a/src/util/virfdstream.c
+++ b/src/util/virfdstream.c
@@ -1435,6 +1435,8 @@ int virFDStreamSetInternalCloseCb(virStr
                                   virFDStreamInternalCloseCbFreeOpaque fcb)
     virFDStreamDataPtr fdst = st->privateData;
+ if (!fdst)
+ return -1;


Lets try to add a check to that, I don't think this is the right solution yet, but maybe with all that insight added later on others on upstream can help again to straighten the fix.