Commit 34242c44 authored by Quentin Schulz's avatar Quentin Schulz Committed by Greg Kroah-Hartman

hwmon: (iio_hwmon) fix memory leak in name attribute

commit 5d17d3b4 upstream.

The "name" variable's memory is now freed when the device is destructed
thanks to devm function.
Signed-off-by: default avatarQuentin Schulz <quentin.schulz@free-electrons.com>
Reported-by: default avatarGuenter Roeck <linux@roeck-us.net>
Fixes: e0f8a24e ("staging:iio::hwmon interface client driver.")
Fixes: 61bb53bc ("hwmon: (iio_hwmon) Add support for humidity sensors")
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6814e928
...@@ -110,24 +110,24 @@ static int iio_hwmon_probe(struct platform_device *pdev) ...@@ -110,24 +110,24 @@ static int iio_hwmon_probe(struct platform_device *pdev)
switch (type) { switch (type) {
case IIO_VOLTAGE: case IIO_VOLTAGE:
a->dev_attr.attr.name = kasprintf(GFP_KERNEL, a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
"in%d_input", "in%d_input",
in_i++); in_i++);
break; break;
case IIO_TEMP: case IIO_TEMP:
a->dev_attr.attr.name = kasprintf(GFP_KERNEL, a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
"temp%d_input", "temp%d_input",
temp_i++); temp_i++);
break; break;
case IIO_CURRENT: case IIO_CURRENT:
a->dev_attr.attr.name = kasprintf(GFP_KERNEL, a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
"curr%d_input", "curr%d_input",
curr_i++); curr_i++);
break; break;
case IIO_HUMIDITYRELATIVE: case IIO_HUMIDITYRELATIVE:
a->dev_attr.attr.name = kasprintf(GFP_KERNEL, a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
"humidity%d_input", "humidity%d_input",
humidity_i++); humidity_i++);
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
......
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