All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arthur Zou <zzou@redhat.com>
To: kexec@lists.infradead.org
Cc: Arthur Zou <zzou@redhat.com>, kumagai-atsushi@mxc.nes.nec.co.jp
Subject: [PATCH v3] Fix free bitmap_buffer_cyclic error
Date: Wed,  7 May 2014 16:53:30 +0800	[thread overview]
Message-ID: <1399452810-3132-1-git-send-email-zzou@redhat.com> (raw)
In-Reply-To: <0910DD04CBD6DE4193FCF86B9C00BE9720EDE2@BPXM01GP.gisp.nec.co.jp>

Description:
In create_dump_bitmap() and write_kdump_pages_and_bitmap_cyclic(),
What should be freed is info->partial_bitmap instead of info->bitmap.

Solution:
Add two functions to free the bitmap_buffer_cyclic. info->partial_bitmap1
is freed by free_bitmap1_buffer_cyclic(). info->partial_bitmap2 is
freed by free_bitmap2_buffer_cyclic(). At the same time, remove
thoes frees that free partial_bitmap1 or partial_bitmap2 at the end
of main() because partial_bitmap1 and partial_bitmap2 has been freed
after dump file has been written out, so there is no need to free it
again at the end of main.

Signed-off-by: Arthur Zou <zzou@redhat.com>
---
 makedumpfile.c | 38 ++++++++++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index 0b31932..d01d5ab 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -5130,6 +5130,31 @@ free_bitmap_buffer(void)
 	free_bitmap2_buffer();
 }
 
+void
+free_bitmap1_buffer_cyclic()
+{
+	if (info->partial_bitmap1 != NULL){
+		free(info->partial_bitmap1);
+		info->partial_bitmap1 = NULL;
+	}
+}
+
+void
+free_bitmap2_buffer_cyclic()
+{
+	if (info->partial_bitmap2 != NULL){
+		free(info->partial_bitmap2);
+		info->partial_bitmap2 = NULL;
+	}
+}
+
+void 
+free_bitmap_buffer_cyclic()
+{
+	free_bitmap1_buffer_cyclic();
+	free_bitmap2_buffer_cyclic();
+}
+
 int
 create_dump_bitmap(void)
 {
@@ -5147,8 +5172,7 @@ create_dump_bitmap(void)
 				goto out;
 
 			info->num_dumpable = get_num_dumpable_cyclic();
-
-			free_bitmap2_buffer();
+			free_bitmap2_buffer_cyclic();
 		}
 
 	} else {
@@ -6190,6 +6214,8 @@ write_elf_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_page)
 	if (!write_cache_bufsz(cd_page))
 		return FALSE;
 
+    free_bitmap_buffer_cyclic();
+
 	/*
 	 * print [100 %]
 	 */
@@ -6947,7 +6973,7 @@ write_kdump_pages_and_bitmap_cyclic(struct cache_data *cd_header, struct cache_d
 	}
 
 
-	free_bitmap1_buffer();
+	free_bitmap1_buffer_cyclic();
 
 	if (!prepare_bitmap2_buffer_cyclic())
 		return FALSE;
@@ -6970,7 +6996,7 @@ write_kdump_pages_and_bitmap_cyclic(struct cache_data *cd_header, struct cache_d
 			return FALSE;
 	}
 
-
+	free_bitmap2_buffer_cyclic();
 
 	gettimeofday(&tv_start, NULL);
 
@@ -9349,10 +9375,6 @@ out:
 			free(info->splitting_info);
 		if (info->p2m_mfn_frame_list != NULL)
 			free(info->p2m_mfn_frame_list);
-		if (info->partial_bitmap1 != NULL)
-			free(info->partial_bitmap1);
-		if (info->partial_bitmap2 != NULL)
-			free(info->partial_bitmap2);
 		free(info);
 	}
 	free_elf_info();
-- 
1.8.4.2


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  reply	other threads:[~2014-05-07  8:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-28  8:48 [PATCH v2] Fix free bitmap_buffer_cyclic error Arthur Zou
2014-05-07  7:39 ` Atsushi Kumagai
2014-05-07  8:53   ` Arthur Zou [this message]
2014-05-08  6:47     ` [PATCH v3] " Atsushi Kumagai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1399452810-3132-1-git-send-email-zzou@redhat.com \
    --to=zzou@redhat.com \
    --cc=kexec@lists.infradead.org \
    --cc=kumagai-atsushi@mxc.nes.nec.co.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.