hwmon: (chipcap2) fix uninitialized variable in cc2_get_reg_val()
authorJavier Carrasco <javier.carrasco.cruz@gmail.com>
Wed, 7 Feb 2024 21:17:08 +0000 (22:17 +0100)
committerGuenter Roeck <linux@roeck-us.net>
Sun, 25 Feb 2024 20:37:38 +0000 (12:37 -0800)
commitf16fb6d23b68699eed97fe1edee0d8eecde14a67
treea733b626214095e8456574891fe798091a095340
parent1b2ca93cd0592b1fcbc6f8b64e02552bc15f4bb4
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>
drivers/hwmon/chipcap2.c