OSDN Git Service

hwmon: (g762) add a check of devm_add_action in g762_of_clock_enable
authorKang Chen <void0red@gmail.com>
Mon, 27 Feb 2023 03:09:12 +0000 (11:09 +0800)
committerGuenter Roeck <linux@roeck-us.net>
Wed, 19 Apr 2023 14:08:31 +0000 (07:08 -0700)
devm_add_action may fails, check it and do the cleanup.

Signed-off-by: Kang Chen <void0red@gmail.com>
Link: https://lore.kernel.org/r/20230227030913.893004-1-void0red@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/g762.c

index 64a0599..e2c3c34 100644 (file)
@@ -620,7 +620,12 @@ static int g762_of_clock_enable(struct i2c_client *client)
        data = i2c_get_clientdata(client);
        data->clk = clk;
 
-       devm_add_action(&client->dev, g762_of_clock_disable, data);
+       ret = devm_add_action(&client->dev, g762_of_clock_disable, data);
+       if (ret) {
+               dev_err(&client->dev, "failed to add disable clock action\n");
+               goto clk_unprep;
+       }
+
        return 0;
 
  clk_unprep: