Commit 07404aab authored by Guenter Roeck's avatar Guenter Roeck Committed by Guenter Roeck

hwmon: (lineage-pem) Convert to use devm_kzalloc

Marginally less code and eliminate the possibility of memory leaks.
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent f352df65
...@@ -448,7 +448,7 @@ static int pem_probe(struct i2c_client *client, ...@@ -448,7 +448,7 @@ static int pem_probe(struct i2c_client *client,
| I2C_FUNC_SMBUS_WRITE_BYTE)) | I2C_FUNC_SMBUS_WRITE_BYTE))
return -ENODEV; return -ENODEV;
data = kzalloc(sizeof(*data), GFP_KERNEL); data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
...@@ -462,11 +462,11 @@ static int pem_probe(struct i2c_client *client, ...@@ -462,11 +462,11 @@ static int pem_probe(struct i2c_client *client,
ret = pem_read_block(client, PEM_READ_FIRMWARE_REV, ret = pem_read_block(client, PEM_READ_FIRMWARE_REV,
data->firmware_rev, sizeof(data->firmware_rev)); data->firmware_rev, sizeof(data->firmware_rev));
if (ret < 0) if (ret < 0)
goto out_kfree; return ret;
ret = i2c_smbus_write_byte(client, PEM_CLEAR_INFO_FLAGS); ret = i2c_smbus_write_byte(client, PEM_CLEAR_INFO_FLAGS);
if (ret < 0) if (ret < 0)
goto out_kfree; return ret;
dev_info(&client->dev, "Firmware revision %d.%d.%d\n", dev_info(&client->dev, "Firmware revision %d.%d.%d\n",
data->firmware_rev[0], data->firmware_rev[1], data->firmware_rev[0], data->firmware_rev[1],
...@@ -475,7 +475,7 @@ static int pem_probe(struct i2c_client *client, ...@@ -475,7 +475,7 @@ static int pem_probe(struct i2c_client *client,
/* Register sysfs hooks */ /* Register sysfs hooks */
ret = sysfs_create_group(&client->dev.kobj, &pem_group); ret = sysfs_create_group(&client->dev.kobj, &pem_group);
if (ret) if (ret)
goto out_kfree; return ret;
/* /*
* Check if input readings are supported. * Check if input readings are supported.
...@@ -534,8 +534,6 @@ static int pem_probe(struct i2c_client *client, ...@@ -534,8 +534,6 @@ static int pem_probe(struct i2c_client *client,
sysfs_remove_group(&client->dev.kobj, &pem_input_group); sysfs_remove_group(&client->dev.kobj, &pem_input_group);
sysfs_remove_group(&client->dev.kobj, &pem_fan_group); sysfs_remove_group(&client->dev.kobj, &pem_fan_group);
sysfs_remove_group(&client->dev.kobj, &pem_group); sysfs_remove_group(&client->dev.kobj, &pem_group);
out_kfree:
kfree(data);
return ret; return ret;
} }
...@@ -549,7 +547,6 @@ static int pem_remove(struct i2c_client *client) ...@@ -549,7 +547,6 @@ static int pem_remove(struct i2c_client *client)
sysfs_remove_group(&client->dev.kobj, &pem_fan_group); sysfs_remove_group(&client->dev.kobj, &pem_fan_group);
sysfs_remove_group(&client->dev.kobj, &pem_group); sysfs_remove_group(&client->dev.kobj, &pem_group);
kfree(data);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment