From: Mikulas Patocka Date: Fri, 5 Jun 2015 13:50:42 +0000 (-0400) Subject: dm stats: fix divide by zero if 'number_of_areas' arg is zero X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=dd4c1b7d0c95be1c9245118a3accc41a16f1db67;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 Signed-off-by: Mike Snitzer Cc: stable@vger.kernel.org # v3.12+ --- 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++;