From: Peter Krempa <pkrempa@redhat.com> Commit 58aa005f3e95114 which refactored how block stats are stored intended to change the code path where stats for all devices are totaled together by allocating new stats object and using that but the commit forgot to actually change the pointers inside the loop. Unfortunately this was not caught by the compiler as there were pre-existing pointers of the same type with the same name, which resulted into a NULL dereference. Fixes: 58aa005f3e95114b4f2dab76ee4ade06182a3f20 Closes: https://gitlab.com/libvirt/libvirt/-/issues/827 Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_driver.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b0eff443aa..5fe4568d98 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9657,6 +9657,8 @@ qemuDomainBlocksStatsGather(virDomainObj *vm, g_autoptr(qemuBlockStats) stats = qemuBlockStatsNew(); for (i = 0; i < vm->def->ndisks; i++) { + qemuBlockStats *entry; + disk = vm->def->disks[i]; entryname = disk->info.alias; @@ -9670,13 +9672,13 @@ qemuDomainBlocksStatsGather(virDomainObj *vm, if (!entryname) continue; - if (!(stats = virHashLookup(blockstats, entryname))) { + if (!(entry = virHashLookup(blockstats, entryname))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot find statistics for device '%1$s'"), entryname); return -1; } - qemuDomainBlockStatsGatherTotals(stats, *retstats); + qemuDomainBlockStatsGatherTotals(entry, stats); } *retstats = g_steal_pointer(&stats); -- 2.51.0