diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2015-06-05 09:50:42 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-08-03 09:29:06 -0700 |
commit | 3198d36127dc9015017926b4d905cc62de962f90 (patch) | |
tree | c9ae11ba370ffa485eaa1dbf0832f51bcfc91979 | |
parent | 3bf9ad4c48534dd0d7f201e315c340069a244664 (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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-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 f478a4c96d2f..419bdd4fc8b8 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++; |