]> git.baikalelectronics.ru Git - kernel.git/commit
hwmon: (occ) Fix division by zero issue
authorLei YU <mine260309@gmail.com>
Thu, 11 Jul 2019 02:44:48 +0000 (10:44 +0800)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 22 Jul 2019 02:18:45 +0000 (19:18 -0700)
commit4c565a969b85926ded890974dfac557cebbe4f2d
tree9c56f175357aa288925d6f09925182832c510599
parent3946fc9291da929ed6836ab79a3b87c34d142954
hwmon: (occ) Fix division by zero issue

The code in occ_get_powr_avg() invokes div64_u64() without checking the
divisor. In case the divisor is zero, kernel gets an "Division by zero
in kernel" error.

Check the divisor and make it return 0 if the divisor is 0.

Fixes: a36e2e2d9fa8 ("hwmon (occ): Add sensor types and versions")
Signed-off-by: Lei YU <mine260309@gmail.com>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/1562813088-23708-1-git-send-email-mine260309@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/occ/common.c