diff options
-rw-r--r-- | drivers/power/max17040_battery.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/power/max17040_battery.c b/drivers/power/max17040_battery.c index 22cfe9cc4727..74a0bd9bc162 100644 --- a/drivers/power/max17040_battery.c +++ b/drivers/power/max17040_battery.c | |||
@@ -207,7 +207,7 @@ static int max17040_probe(struct i2c_client *client, | |||
207 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) | 207 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) |
208 | return -EIO; | 208 | return -EIO; |
209 | 209 | ||
210 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 210 | chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); |
211 | if (!chip) | 211 | if (!chip) |
212 | return -ENOMEM; | 212 | return -ENOMEM; |
213 | 213 | ||
@@ -225,7 +225,6 @@ static int max17040_probe(struct i2c_client *client, | |||
225 | ret = power_supply_register(&client->dev, &chip->battery); | 225 | ret = power_supply_register(&client->dev, &chip->battery); |
226 | if (ret) { | 226 | if (ret) { |
227 | dev_err(&client->dev, "failed: power supply register\n"); | 227 | dev_err(&client->dev, "failed: power supply register\n"); |
228 | kfree(chip); | ||
229 | return ret; | 228 | return ret; |
230 | } | 229 | } |
231 | 230 | ||
@@ -244,7 +243,6 @@ static int max17040_remove(struct i2c_client *client) | |||
244 | 243 | ||
245 | power_supply_unregister(&chip->battery); | 244 | power_supply_unregister(&chip->battery); |
246 | cancel_delayed_work(&chip->work); | 245 | cancel_delayed_work(&chip->work); |
247 | kfree(chip); | ||
248 | return 0; | 246 | return 0; |
249 | } | 247 | } |
250 | 248 | ||