hwmon: (gpio-fan) Check return value from devm_add_action_or_reset
authorGuenter Roeck <linux@roeck-us.net>
Fri, 7 Jun 2019 20:19:12 +0000 (13:19 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 24 Jun 2019 01:32:34 +0000 (18:32 -0700)
devm_add_action_or_reset() can fail due to a memory allocation failure.
Check for it and return the error if that happens.

Fixes: 9534784550ab ("hwmon: (gpio-fan) Use devm_thermal_of_cooling_device_register")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/gpio-fan.c

index 84753680a4e8cab9653bf13f02cbce63dcdb0671..54c27e683ee10cf96b6cc7260f9cab6bb3c515f0 100644 (file)
@@ -524,7 +524,9 @@ static int gpio_fan_probe(struct platform_device *pdev)
                err = fan_ctrl_init(fan_data);
                if (err)
                        return err;
-               devm_add_action_or_reset(dev, gpio_fan_stop, fan_data);
+               err = devm_add_action_or_reset(dev, gpio_fan_stop, fan_data);
+               if (err)
+                       return err;
        }
 
        /* Make this driver part of hwmon class. */