Skip to content

Commit

Permalink
dm stats: fix divide by zero if 'number_of_areas' arg is zero
Browse files Browse the repository at this point in the history
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+
  • Loading branch information
Mikulas Patocka authored and Mike Snitzer committed Jun 17, 2015
1 parent bccab6a commit dd4c1b7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/md/dm-stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down

0 comments on commit dd4c1b7

Please sign in to comment.