mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-09 10:11:52 -04:00
power: sbs-battery: Use devm_kzalloc to alloc data
Use devm_kzalloc to allow memory to be freed automatically on driver probe failure or removal. Signed-off-by: Phil Reid <preid@electromag.com.au> Signed-off-by: Sebastian Reichel <sre@kernel.org>
This commit is contained in:
committed by
Sebastian Reichel
parent
e4a404a081
commit
9239a86f09
@@ -819,7 +819,7 @@ static int sbs_probe(struct i2c_client *client,
|
||||
if (!sbs_desc->name)
|
||||
return -ENOMEM;
|
||||
|
||||
chip = kzalloc(sizeof(struct sbs_info), GFP_KERNEL);
|
||||
chip = devm_kzalloc(&client->dev, sizeof(struct sbs_info), GFP_KERNEL);
|
||||
if (!chip)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -920,8 +920,6 @@ static int sbs_probe(struct i2c_client *client,
|
||||
if (chip->gpio_detect)
|
||||
gpio_free(pdata->battery_detect);
|
||||
|
||||
kfree(chip);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -938,9 +936,6 @@ static int sbs_remove(struct i2c_client *client)
|
||||
|
||||
cancel_delayed_work_sync(&chip->work);
|
||||
|
||||
kfree(chip);
|
||||
chip = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user