diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2015-06-05 09:50:42 -0400 |
---|---|---|
committer | Jiri Slaby <jslaby@suse.cz> | 2015-08-04 16:52:15 +0200 |
commit | b4ca5e5571316d94f6d03a68716d3015cd2441f0 (patch) | |
tree | c3b0bc4961cb881609a2415f09a1e136b5c8da15 /drivers | |
parent | 28d1a88bcd8f76794fd541f2f4c1f07debbe05f6 (diff) |
dm stats: fix divide by zero if 'number_of_areas' arg is zero
commit dd4c1b7d0c95be1c9245118a3accc41a16f1db67 upstream.
If the number_of_areas argument was zero the kernel would crash on
div-by-zero. Add better input validation.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/dm-stats.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c index 28a90122a5a8..b3b0697a9fd7 100644 --- a/drivers/md/dm-stats.c +++ b/drivers/md/dm-stats.c @@ -795,6 +795,8 @@ static int message_stats_create(struct mapped_device *md, return -EINVAL; if (sscanf(argv[2], "/%u%c", &divisor, &dummy) == 1) { + if (!divisor) + return -EINVAL; step = end - start; if (do_div(step, divisor)) step++; |