summaryrefslogtreecommitdiff
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorQuentin Schulz <quentin.schulz@free-electrons.com>2016-07-26 10:47:09 +0300
committerGuenter Roeck <linux@roeck-us.net>2016-08-01 01:02:52 +0300
commit5d17d3b4bbf3becb89fd48b74340a50a39736f6d (patch)
tree879614286b3ba1b112f2bd246ab79d0ade44fc28 /drivers/hwmon
parent4c8702b3cd43322ca97fdc7f647e273a7388a0c6 (diff)
downloadlinux-5d17d3b4bbf3becb89fd48b74340a50a39736f6d.tar.xz
hwmon: (iio_hwmon) fix memory leak in name attribute
The "name" variable's memory is now freed when the device is destructed thanks to devm function. Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com> Reported-by: Guenter Roeck <linux@roeck-us.net> Fixes: e0f8a24e0edfd ("staging:iio::hwmon interface client driver.") Fixes: 61bb53bcbdd86 ("hwmon: (iio_hwmon) Add support for humidity sensors") Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/iio_hwmon.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
index b550ba5fa58a..89449871bca7 100644
--- a/drivers/hwmon/iio_hwmon.c
+++ b/drivers/hwmon/iio_hwmon.c
@@ -110,24 +110,24 @@ static int iio_hwmon_probe(struct platform_device *pdev)
switch (type) {
case IIO_VOLTAGE:
- a->dev_attr.attr.name = kasprintf(GFP_KERNEL,
- "in%d_input",
- in_i++);
+ a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
+ "in%d_input",
+ in_i++);
break;
case IIO_TEMP:
- a->dev_attr.attr.name = kasprintf(GFP_KERNEL,
- "temp%d_input",
- temp_i++);
+ a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
+ "temp%d_input",
+ temp_i++);
break;
case IIO_CURRENT:
- a->dev_attr.attr.name = kasprintf(GFP_KERNEL,
- "curr%d_input",
- curr_i++);
+ a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
+ "curr%d_input",
+ curr_i++);
break;
case IIO_HUMIDITYRELATIVE:
- a->dev_attr.attr.name = kasprintf(GFP_KERNEL,
- "humidity%d_input",
- humidity_i++);
+ a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
+ "humidity%d_input",
+ humidity_i++);
break;
default:
ret = -EINVAL;