hwmon: (npcm750-pwm) Add an error code check in npcm7xx_en_pwm_fan
authorSu Hui <suhui@nfschina.com>
Fri, 20 Oct 2023 08:55:19 +0000 (16:55 +0800)
committerGuenter Roeck <linux@roeck-us.net>
Sat, 28 Oct 2023 16:21:36 +0000 (09:21 -0700)
npcm7xx_pwm_config_set() can return '-ENODEV' for failed. So check
the value of 'ret' after calling npcm7xx_pwm_config_set().

Signed-off-by: Su Hui <suhui@nfschina.com>
Link: https://lore.kernel.org/r/20231020085518.198477-1-suhui@nfschina.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/npcm750-pwm-fan.c

index 10ed3f4335d472b87f07139704542f119c1765ec..4702e4edc662df4f311b691bd772ea1d340ddbf6 100644 (file)
@@ -875,6 +875,8 @@ static int npcm7xx_en_pwm_fan(struct device *dev,
        data->pwm_present[pwm_port] = true;
        ret = npcm7xx_pwm_config_set(data, pwm_port,
                                     NPCM7XX_PWM_CMR_DEFAULT_NUM);
+       if (ret)
+               return ret;
 
        ret = of_property_count_u8_elems(child, "cooling-levels");
        if (ret > 0) {