]> www.infradead.org Git - users/dwmw2/linux.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Aug 2019 08:11:02 +0000 (10:11 +0200)
commit5f674df02255bb7c4aa0190a945f0868b61ff31d
treed6f05e7f527d4b2401ed2b7d8426666d5f6107fe
parentb95697c8e29f34331ef28aa2404bf6d86674bcd7
hwmon: (occ) Fix division by zero issue

[ Upstream commit 211186cae14de09573b062e478eb9fe215aed8d9 ]

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: c10e753d43eb ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hwmon/occ/common.c