From f696b74b15f641c23c3f1aa644a3f2a98c0a87e1 Mon Sep 17 00:00:00 2001 From: Miaoqian Lin Date: Fri, 24 Jun 2022 10:31:59 +0400 Subject: 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") Signed-off-by: Miaoqian Lin Message-Id: <20220624063159.57411-1-linmq006@gmail.com> Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 1 + 1 file changed, 1 insertion(+) (limited to 'accel/kvm') diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index ba3210b..ed8b6b8 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -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; -- cgit v1.1