summaryrefslogtreecommitdiff
path: root/scripts/rustdoc_test_builder.rs
diff options
context:
space:
mode:
authorAlexey Simakov <bigalex934@gmail.com>2025-12-11 19:43:43 +0300
committerGuenter Roeck <linux@roeck-us.net>2025-12-14 09:52:28 -0800
commit82f2aab35a1ab2e1460de06ef04c726460aed51c (patch)
treef982f2b88aacae4007430f48fa0d78f761188f9e /scripts/rustdoc_test_builder.rs
parent6946c726c3f4c36f0f049e6f97e88c510b15f65d (diff)
hwmon: (tmp401) fix overflow caused by default conversion rate value
The driver computes conversion intervals using the formula: interval = (1 << (7 - rate)) * 125ms where 'rate' is the sensor's conversion rate register value. According to the datasheet, the power-on reset value of this register is 0x8, which could be assigned to the register, after handling i2c general call. Using this default value causes a result greater than the bit width of left operand and an undefined behaviour in the calculation above, since shifting by values larger than the bit width is undefined behaviour as per C language standard. Limit the maximum usable 'rate' value to 7 to prevent undefined behaviour in calculations. Found by Linux Verification Center (linuxtesting.org) with Svace. Note (groeck): This does not matter in practice unless someone overwrites the chip configuration from outside the driver while the driver is loaded. The conversion time register is initialized with a value of 5 (500ms) when the driver is loaded, and the driver never writes a bad value. Fixes: ca53e7640de7 ("hwmon: (tmp401) Convert to _info API") Signed-off-by: Alexey Simakov <bigalex934@gmail.com> Link: https://lore.kernel.org/r/20251211164342.6291-1-bigalex934@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'scripts/rustdoc_test_builder.rs')
0 files changed, 0 insertions, 0 deletions