hwmon: (chipcap2) fix return path in cc2_request_alarm_irqs()
authorJavier Carrasco <javier.carrasco.cruz@gmail.com>
Wed, 7 Feb 2024 21:17:09 +0000 (22:17 +0100)
committerGuenter Roeck <linux@roeck-us.net>
Sun, 25 Feb 2024 20:37:42 +0000 (12:37 -0800)
commitefd49b8eef659e0aa962ec1dbf18740e34735219
tree5802604b7183974842e030411f3f9753b4c534c4
parentf16fb6d23b68699eed97fe1edee0d8eecde14a67
hwmon: (chipcap2) fix return path in cc2_request_alarm_irqs()

The return path can be improved by returning upon first failure. The
current implementation would try to register the second interrupt even
if the first one failed, which is unnecessary.

Moreover, if no irqs are available, the return value should be zero
(the driver supports the use case with no interrupts). Currently the
initial value is unassigned and that may lead to returning an unknown
value if stack variables are not automatically set to zero and no irqs
were provided.

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-2-08cafe43e20e@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/chipcap2.c