Skip to contentSkip to conversation

accel: kvm: Fix memory leak in find_stats_descriptors

PATCH Applied Miaoqian Lin 2 participants 2 messages Jun 24, 2022 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 accel: kvm: Fix memory leak in find_stats_descriptors

This function doesn't release descriptors in one error path, result in memory leak. Call g_free() to release it.

Fixes cc01a3f4cadd ("kvm: Support for querying fd-based stats")
---
 accel/kvm/kvm-all.c | 1 +
 1 file changed, 1 insertion(+)
accel/kvm/kvm-all.c +1 -0
index ba3210b1c10d..ed8b6b896ed3 100644
@@ -3891,6 +3891,7 @@ static StatsDescriptors *find_stats_descriptors(StatsTarget target, int stats_fd
         error_setg(errp, "KVM stats: failed to read stats header: "
                    "expected %zu actual %zu",
                    sizeof(*kvm_stats_header), ret);
+        g_free(descriptors);
         return NULL;
     }
     size_desc = sizeof(*kvm_stats_desc) + kvm_stats_header->name_size;
Signature · 1 line
2.25.1