Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hwmon: (k10temp) Check return value of hygon_read_temp()
Check the return value of amd_smn_read() before saving a value. This ensures invalid values aren't saved or used. There are three cases here with slightly different behavior. 1) read_tempreg_nb_zen(): This is a function pointer which does not include a return code. In this case, set the register value to 0 on failure. This enforces Read-as-Zero behavior. 2) k10temp_read_temp(): This function does have return codes, so return the error code from the failed register read. Continued operation is not necessary, since there is no valid data from the register. Furthermore, if the register value was set to 0, then the following operation would underflow. 3) k10temp_get_ccd_support(): This function reads the same register from multiple CCD instances in a loop. And a bitmask is formed if a specific bit is set in each register instance. The loop should continue on a failed register read, skipping the bit check. WangYuli: When check amd_smn_read(), don't forget Hygon. Thanks for code review from Hygon. Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.11-rc6&id=c2d79cc5455c891de6c93e1e0c73d806e299c54f Link: d693d4a Signed-off-by: WangYuli <[email protected]>
- Loading branch information