mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
hwmon: (chipcap2) fix uninitialized variable in cc2_get_reg_val()
The reg_val variable in cc2_get_reg_val() might be used without a known value if cc2_read_reg() fails. That leads to a useless data conversion because the returned error means the read operation failed and the data is not relevant. That makes its initial value irrelevant as well, so skip the data conversion instead. If no error happens, a value is assigned to reg_val and the data conversion is required. Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/linux-hwmon/294e4634-89d4-415e-a723-b208d8770d7c@gmail.com/T/#t Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://lore.kernel.org/r/20240207-chipcap2_init_vars-v1-1-08cafe43e20e@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
1b2ca93cd0
commit
f16fb6d23b
1 changed files with 3 additions and 1 deletions
|
@ -324,7 +324,9 @@ static int cc2_get_reg_val(struct cc2_data *data, u8 reg, long *val)
|
|||
int ret;
|
||||
|
||||
ret = cc2_read_reg(data, reg, ®_val);
|
||||
*val = cc2_rh_convert(reg_val);
|
||||
if (!ret)
|
||||
*val = cc2_rh_convert(reg_val);
|
||||
|
||||
cc2_disable(data);
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue