File patch-xen-fix-wrong-free-issue-in-init_xen_crash_inf.patch of Package makedumpfile.28153

From: Dietmar Hahn <dietmar.hahn@fujitsu.com>
Subject: [PATCH] xen: Fix wrong free issue in init_xen_crash_info()
Git-commit: a2136943b1f173d2bf7efffc29542556e38aa564
Patch-mainline: 1.7.2~2
References: bsc#1201209
Acked-by: Jiri Bohac <jbohac@suse.cz>

The commit 2651d5719a21 ("[PATCH 11/14] fix memory leak in
init_xen_crash_info()") changed the behaviour of the function and the
buf variable is always released, but it's still used later when
returning TRUE.  Without the patch, this leads to random data in the
buffer and later to the following error:

  get_xen_basic_info_x86_64: Can't get the symbol of xenheap_phys_end.

Fixes: 2651d5719a21 ("[PATCH 11/14] fix memory leak in init_xen_crash_info()")
Signed-off-by: Dietmar Hahn <dietmar.hahn@fujitsu.com>
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>

diff --git a/makedumpfile.c b/makedumpfile.c
index 65d1c7c..ff821eb 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -9668,7 +9668,6 @@ init_xen_crash_info(void)
 {
 	off_t		offset_xen_crash_info;
 	unsigned long	size_xen_crash_info;
-	int		ret = FALSE;
 	void		*buf;
 
 	get_xen_crash_info(&offset_xen_crash_info, &size_xen_crash_info);
@@ -9710,11 +9709,11 @@ init_xen_crash_info(void)
 	else
 		info->xen_crash_info_v = 0;
 
-	ret = TRUE;
+	return TRUE;
 
 out_error:
 	free(buf);
-	return ret;
+	return FALSE;
 }
 
 int
@@ -12377,6 +12376,8 @@ out:
 			free(info->dump_header);
 		if (info->splitting_info != NULL)
 			free(info->splitting_info);
+		if (info->xen_crash_info.com != NULL)
+			free(info->xen_crash_info.com);
 		if (info->p2m_mfn_frame_list != NULL)
 			free(info->p2m_mfn_frame_list);
 		if (info->page_buf != NULL)
-- 
2.38.1

openSUSE Build Service is sponsored by