diff options
author | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-04-23 13:39:00 -0400 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-05-20 22:41:49 -0400 |
commit | 41141e64e63dd250a05218b66c91e125f1020b92 (patch) | |
tree | 746bb6545c51543d735e31a78288274a71ffe5ab /drivers/hwmon | |
parent | 1137a9a649db818869905b010b120a95a01b0d24 (diff) |
hwmon: (ntc_thermistor) Convert to devm_kzalloc
This avoids memory leaks, and makes the code a bit simpler and smaller.
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Reviewed-by: Robert Coulson <robert.coulson@ericsson.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/ntc_thermistor.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c index 9b382ec2c3bd..4be7faff321b 100644 --- a/drivers/hwmon/ntc_thermistor.c +++ b/drivers/hwmon/ntc_thermistor.c | |||
@@ -349,7 +349,7 @@ static int __devinit ntc_thermistor_probe(struct platform_device *pdev) | |||
349 | return -EINVAL; | 349 | return -EINVAL; |
350 | } | 350 | } |
351 | 351 | ||
352 | data = kzalloc(sizeof(struct ntc_data), GFP_KERNEL); | 352 | data = devm_kzalloc(&pdev->dev, sizeof(struct ntc_data), GFP_KERNEL); |
353 | if (!data) | 353 | if (!data) |
354 | return -ENOMEM; | 354 | return -ENOMEM; |
355 | 355 | ||
@@ -370,8 +370,7 @@ static int __devinit ntc_thermistor_probe(struct platform_device *pdev) | |||
370 | dev_err(&pdev->dev, "Unknown device type: %lu(%s)\n", | 370 | dev_err(&pdev->dev, "Unknown device type: %lu(%s)\n", |
371 | pdev->id_entry->driver_data, | 371 | pdev->id_entry->driver_data, |
372 | pdev->id_entry->name); | 372 | pdev->id_entry->name); |
373 | ret = -EINVAL; | 373 | return -EINVAL; |
374 | goto err; | ||
375 | } | 374 | } |
376 | 375 | ||
377 | platform_set_drvdata(pdev, data); | 376 | platform_set_drvdata(pdev, data); |
@@ -379,7 +378,7 @@ static int __devinit ntc_thermistor_probe(struct platform_device *pdev) | |||
379 | ret = sysfs_create_group(&data->dev->kobj, &ntc_attr_group); | 378 | ret = sysfs_create_group(&data->dev->kobj, &ntc_attr_group); |
380 | if (ret) { | 379 | if (ret) { |
381 | dev_err(data->dev, "unable to create sysfs files\n"); | 380 | dev_err(data->dev, "unable to create sysfs files\n"); |
382 | goto err; | 381 | return ret; |
383 | } | 382 | } |
384 | 383 | ||
385 | data->hwmon_dev = hwmon_device_register(data->dev); | 384 | data->hwmon_dev = hwmon_device_register(data->dev); |
@@ -395,8 +394,6 @@ static int __devinit ntc_thermistor_probe(struct platform_device *pdev) | |||
395 | return 0; | 394 | return 0; |
396 | err_after_sysfs: | 395 | err_after_sysfs: |
397 | sysfs_remove_group(&data->dev->kobj, &ntc_attr_group); | 396 | sysfs_remove_group(&data->dev->kobj, &ntc_attr_group); |
398 | err: | ||
399 | kfree(data); | ||
400 | return ret; | 397 | return ret; |
401 | } | 398 | } |
402 | 399 | ||
@@ -408,8 +405,6 @@ static int __devexit ntc_thermistor_remove(struct platform_device *pdev) | |||
408 | sysfs_remove_group(&data->dev->kobj, &ntc_attr_group); | 405 | sysfs_remove_group(&data->dev->kobj, &ntc_attr_group); |
409 | platform_set_drvdata(pdev, NULL); | 406 | platform_set_drvdata(pdev, NULL); |
410 | 407 | ||
411 | kfree(data); | ||
412 | |||
413 | return 0; | 408 | return 0; |
414 | } | 409 | } |
415 | 410 | ||