diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2015-06-05 15:50:42 +0200 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2015-06-17 18:40:39 +0200 |
commit | dd4c1b7d0c95be1c9245118a3accc41a16f1db67 (patch) | |
tree | 3f2ba6693d124977cd18155d132f52a1de20c9b2 /drivers/md/dm-stats.c | |
parent | dm cache: switch the "default" cache replacement policy from mq to smq (diff) | |
download | linux-dd4c1b7d0c95be1c9245118a3accc41a16f1db67.tar.xz linux-dd4c1b7d0c95be1c9245118a3accc41a16f1db67.zip |
dm stats: fix divide by zero if 'number_of_areas' arg is zero
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>
Cc: stable@vger.kernel.org # v3.12+
Diffstat (limited to 'drivers/md/dm-stats.c')
-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 492fe6a5ebf2..d1fd31a6dd1a 100644 --- a/drivers/md/dm-stats.c +++ b/drivers/md/dm-stats.c @@ -792,6 +792,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++; |