From: Wang Nan <wangnan0@huawei.com>
To: Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>
Cc: Wang Nan <wangnan0@huawei.com>, Simon Horman <horms@verge.net.au>,
kexec@lists.infradead.org, Geng Hui <hui.geng@huawei.com>
Subject: [PATCH] makedumpfile: bugfix: fix a div-by-zero problem
Date: Fri, 4 Apr 2014 15:19:52 +0800 [thread overview]
Message-ID: <1396595992-65949-1-git-send-email-wangnan0@huawei.com> (raw)
In makedumpfile.c, we want the progress printed 10000 times.
It is tested by:
(num_dumped % per) == 0
where per is num_dumpable / 10000.
However, if num_dumpable less than 10000, num_dumped % per causes a
divide-by-zero problem, triggers a SIGFPE.
This patch makes sure per never be 0.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>
Cc: kexec@lists.infradead.org
Cc: Geng Hui <hui.geng@huawei.com>
Cc: Simon Horman <horms@verge.net.au>
---
makedumpfile.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/makedumpfile.c b/makedumpfile.c
index 23251a1..d71977a 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -5621,6 +5621,7 @@ write_elf_pages(struct cache_data *cd_header, struct cache_data *cd_page)
num_dumpable = get_num_dumpable();
per = num_dumpable / 10000;
+ per = per ? per : 1;
off_seg_load = info->offset_load_dumpfile;
cd_page->offset = info->offset_load_dumpfile;
@@ -5906,6 +5907,7 @@ write_elf_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_page)
num_dumpable = info->num_dumpable;
per = num_dumpable / 10000;
+ per = per ? per : 1;
off_seg_load = info->offset_load_dumpfile;
cd_page->offset = info->offset_load_dumpfile;
@@ -6164,6 +6166,7 @@ write_kdump_pages(struct cache_data *cd_header, struct cache_data *cd_page)
num_dumpable = get_num_dumpable();
per = num_dumpable / 10000;
+ per = per ? per : 1;
/*
* Calculate the offset of the page data.
@@ -6365,6 +6368,7 @@ write_kdump_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_pag
}
per = info->num_dumpable / 10000;
+ per = per ? per : 1;
/*
* Set a fileoffset of Physical Address 0x0.
--
1.8.4
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next reply other threads:[~2014-04-04 7:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-04 7:19 Wang Nan [this message]
2014-04-08 2:30 ` [PATCH] makedumpfile: bugfix: fix a div-by-zero problem 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=1396595992-65949-1-git-send-email-wangnan0@huawei.com \
--to=wangnan0@huawei.com \
--cc=horms@verge.net.au \
--cc=hui.geng@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox