Fix free bitmap_buffer_cyclic error
Subsystems (2)
PATCH v2 1/1 Fix free bitmap_buffer_cyclic error
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 at the end of write_kdump_pages_and_bitmap_cyclic(), so there is no need to free it again at the end of main.
--- makedumpfile.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
makedumpfile.c +19 -8
@@ -5130,6 +5130,22 @@ 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 ; + } +} +int create_dump_bitmap (void ) {
@@ -5147,8 +5163,7 @@ create_dump_bitmap(void) goto out; info->num_dumpable =get_num_dumpable_cyclic (); - -free_bitmap2_buffer (); +free_bitmap2_buffer_cyclic (); } }else {
@@ -6947,7 +6962,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 +6985,7 @@ write_kdump_pages_and_bitmap_cyclic(struct cache_data *cd_header, struct cache_dreturn FALSE; } - +free_bitmap2_buffer_cyclic ();gettimeofday (&tv_start,NULL );
@@ -9349,10 +9364,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 ();
Signature · 7 lines
1.8.4.2 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Quoted 4 lines
Description:
Increate_dump_bitmap()andwrite_kdump_pages_and_bitmap_cyclic(), What should be freed isinfo->partial_bitmapinstead ofinfo->bitmap.
Quoted 8 lines
Solution:
Add two functions to free thebitmap_buffer_cyclic.info->partial_bitmap1is freed byfree_bitmap1_buffer_cyclic().info->partial_bitmap2is freed byfree_bitmap2_buffer_cyclic(). At the same time, remove thoes frees that freepartial_bitmap1orpartial_bitmap2at the end ofmain()becausepartial_bitmap1andpartial_bitmap2has been freed at the end ofwrite_kdump_pages_and_bitmap_cyclic(), so there is no need to free it again at the end of main.
It seems that I didn't make myself clear, sorry.
partial_bitmap(1|2) will not be freed in the case of ELF format, so you should call free_bitmap(1|2)_buffer_cyclic() in write_elf_pages_cyclic() as well.
Thanks
Atsushi Kumagai
Quoted 72 lines
Signed-off-by Arthur Zou <[email protected]>---
makedumpfile.c| 27 +++++++++++++++++++--------1 file changed, 19 insertions(+), 8 deletions(-)makedumpfile.c +16
-0@@ -5130,6 +5130,22 @@ 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 ; + } +} +int
create_dump_bitmap(void)
{makedumpfile.c +3
-9@@ -5147,8 +5163,7 @@ create_dump_bitmap(void) goto out; info->num_dumpable =get_num_dumpable_cyclic (); - -free_bitmap2_buffer (); +free_bitmap2_buffer_cyclic (); } }else {@@ -6947,7 +6962,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 +6985,7 @@ write_kdump_pages_and_bitmap_cyclic(struct cache_data *cd_header, struct cache_dreturn FALSE; } - +free_bitmap2_buffer_cyclic ();gettimeofday (&tv_start,NULL );@@ -9349,10 +9364,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 (); --
Quoted 1 line
1.8.4.2
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v3 1/1 Fix free bitmap_buffer_cyclic error
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.
--- makedumpfile.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-)
makedumpfile.c +30 -8
@@ -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_dreturn 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 ();
Signature · 7 lines
1.8.4.2 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Quoted 4 lines
Description:
Increate_dump_bitmap()andwrite_kdump_pages_and_bitmap_cyclic(), What should be freed isinfo->partial_bitmapinstead ofinfo->bitmap.
Quoted 8 lines
Solution:
Add two functions to free thebitmap_buffer_cyclic.info->partial_bitmap1is freed byfree_bitmap1_buffer_cyclic().info->partial_bitmap2is freed byfree_bitmap2_buffer_cyclic(). At the same time, remove thoes frees that freepartial_bitmap1orpartial_bitmap2at the end ofmain()becausepartial_bitmap1andpartial_bitmap2has been freed after dump file has been written out, so there is no need to free it again at the end of main.
Good, I'll merge this patch into v1.5.7.
Thanks
Atsushi Kumagai
Quoted 90 lines
Signed-off-by Arthur Zou <[email protected]>---
makedumpfile.c| 38 ++++++++++++++++++++++++++++++--------1 file changed, 30 insertions(+), 8 deletions(-)makedumpfile.c +25
-0@@ -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)
{makedumpfile.c +5
-9@@ -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_dreturn 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 (); --
Quoted 1 line
1.8.4.2
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec