Commit 41141e64 authored by Guenter Roeck's avatar Guenter Roeck

hwmon: (ntc_thermistor) Convert to devm_kzalloc

This avoids memory leaks, and makes the code a bit simpler and smaller.
Signed-off-by: default avatarGuenter Roeck <guenter.roeck@ericsson.com>
Reviewed-by: default avatarRobert Coulson <robert.coulson@ericsson.com>
parent 1137a9a6
...@@ -349,7 +349,7 @@ static int __devinit ntc_thermistor_probe(struct platform_device *pdev) ...@@ -349,7 +349,7 @@ static int __devinit ntc_thermistor_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
data = kzalloc(sizeof(struct ntc_data), GFP_KERNEL); data = devm_kzalloc(&pdev->dev, sizeof(struct ntc_data), GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
...@@ -370,8 +370,7 @@ static int __devinit ntc_thermistor_probe(struct platform_device *pdev) ...@@ -370,8 +370,7 @@ static int __devinit ntc_thermistor_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Unknown device type: %lu(%s)\n", dev_err(&pdev->dev, "Unknown device type: %lu(%s)\n",
pdev->id_entry->driver_data, pdev->id_entry->driver_data,
pdev->id_entry->name); pdev->id_entry->name);
ret = -EINVAL; return -EINVAL;
goto err;
} }
platform_set_drvdata(pdev, data); platform_set_drvdata(pdev, data);
...@@ -379,7 +378,7 @@ static int __devinit ntc_thermistor_probe(struct platform_device *pdev) ...@@ -379,7 +378,7 @@ static int __devinit ntc_thermistor_probe(struct platform_device *pdev)
ret = sysfs_create_group(&data->dev->kobj, &ntc_attr_group); ret = sysfs_create_group(&data->dev->kobj, &ntc_attr_group);
if (ret) { if (ret) {
dev_err(data->dev, "unable to create sysfs files\n"); dev_err(data->dev, "unable to create sysfs files\n");
goto err; return ret;
} }
data->hwmon_dev = hwmon_device_register(data->dev); data->hwmon_dev = hwmon_device_register(data->dev);
...@@ -395,8 +394,6 @@ static int __devinit ntc_thermistor_probe(struct platform_device *pdev) ...@@ -395,8 +394,6 @@ static int __devinit ntc_thermistor_probe(struct platform_device *pdev)
return 0; return 0;
err_after_sysfs: err_after_sysfs:
sysfs_remove_group(&data->dev->kobj, &ntc_attr_group); sysfs_remove_group(&data->dev->kobj, &ntc_attr_group);
err:
kfree(data);
return ret; return ret;
} }
...@@ -408,8 +405,6 @@ static int __devexit ntc_thermistor_remove(struct platform_device *pdev) ...@@ -408,8 +405,6 @@ static int __devexit ntc_thermistor_remove(struct platform_device *pdev)
sysfs_remove_group(&data->dev->kobj, &ntc_attr_group); sysfs_remove_group(&data->dev->kobj, &ntc_attr_group);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
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