]> www.infradead.org Git - users/jedix/linux-maple.git/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:06 +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 f478a4c96d2f55cb2cf75abe50bfc2ce365c2a8e..419bdd4fc8b8ef062b8b39ba61f24c1911ce9ba4 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++;