提交 5d17d3b4 编写于 作者: Q Quentin Schulz 提交者: Guenter Roeck

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: NQuentin Schulz <quentin.schulz@free-electrons.com>
Reported-by: NGuenter 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: NGuenter Roeck <linux@roeck-us.net>
上级 4c8702b3
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册