]> git.hungrycats.org Git - linux/commitdiff
dm stats: fix divide by zero if 'number_of_areas' arg is zero
authorMikulas Patocka <mpatocka@redhat.com>
Fri, 5 Jun 2015 13:50:42 +0000 (09:50 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Aug 2015 16:29:55 +0000 (09:29 -0700)
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>
drivers/md/dm-stats.c

index 28a90122a5a89272f5873ed0911d2de19125c15b..b3b0697a9fd77550b3d06ba812e2be510a18d491 100644 (file)
@@ -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++;