pwm: mediatek: Prevent divide-by-zero in pwm_mediatek_config()
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ caf065f8fd583b43a3f95d84c8a0a0d07597963b · < 4cb15042b5f3ec0474e91cf379120cc597625dbb| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
pwm: mediatek: Prevent divide-by-zero in pwm_mediatek_config()
With CONFIG_COMPILE_TEST && !CONFIG_HAVE_CLK, pwm_mediatek_config() has a divide-by-zero in the following line:
do_div(resolution, clk_get_rate(pc->clk_pwms[pwm->hwpwm]));
due to the fact that the !CONFIG_HAVE_CLK version of clk_get_rate() returns zero.
This is presumably just a theoretical problem: COMPILE_TEST overrides the dependency on RALINK which would select COMMON_CLK. Regardless it's a good idea to check for the error explicitly to avoid divide-by-zero.
Fixes the following warning:
drivers/pwm/pwm-mediatek.o: warning: objtool: .text: unexpected end of section
From the CVE record · Linux
The Linux kernel's MediaTek PWM driver can divide by zero in pwm_mediatek_config() when built with CONFIG_COMPILE_TEST and without CONFIG_HAVE_CLK. The report describes this as presumably theoretical and does not identify an attacker path, authentication requirement, or user interaction.
Engineers running Linux kernels built with CONFIG_COMPILE_TEST and without CONFIG_HAVE_CLK should check their builds; affected versions are not specified.