Input: soc_button_array - fix leaking the ACPI button descriptor buffer
We are passing a buffer with ACPI_ALLOCATE_BUFFER set to acpi_evaluate_object, so we must free it when we are done with it. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
a0897d5f2c
commit
779f19ac9d
|
@ -248,7 +248,8 @@ static struct soc_button_info *soc_button_get_button_info(struct device *dev)
|
||||||
|
|
||||||
if (!btns_desc) {
|
if (!btns_desc) {
|
||||||
dev_err(dev, "ACPI Button Descriptors not found\n");
|
dev_err(dev, "ACPI Button Descriptors not found\n");
|
||||||
return ERR_PTR(-ENODEV);
|
button_info = ERR_PTR(-ENODEV);
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The first package describes the collection */
|
/* The first package describes the collection */
|
||||||
|
@ -264,24 +265,31 @@ static struct soc_button_info *soc_button_get_button_info(struct device *dev)
|
||||||
}
|
}
|
||||||
if (collection_uid == -1) {
|
if (collection_uid == -1) {
|
||||||
dev_err(dev, "Invalid Button Collection Descriptor\n");
|
dev_err(dev, "Invalid Button Collection Descriptor\n");
|
||||||
return ERR_PTR(-ENODEV);
|
button_info = ERR_PTR(-ENODEV);
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* There are package.count - 1 buttons + 1 terminating empty entry */
|
/* There are package.count - 1 buttons + 1 terminating empty entry */
|
||||||
button_info = devm_kcalloc(dev, btns_desc->package.count,
|
button_info = devm_kcalloc(dev, btns_desc->package.count,
|
||||||
sizeof(*button_info), GFP_KERNEL);
|
sizeof(*button_info), GFP_KERNEL);
|
||||||
if (!button_info)
|
if (!button_info) {
|
||||||
return ERR_PTR(-ENOMEM);
|
button_info = ERR_PTR(-ENOMEM);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
/* Parse the button descriptors */
|
/* Parse the button descriptors */
|
||||||
for (i = 1, btn = 0; i < btns_desc->package.count; i++, btn++) {
|
for (i = 1, btn = 0; i < btns_desc->package.count; i++, btn++) {
|
||||||
if (soc_button_parse_btn_desc(dev,
|
if (soc_button_parse_btn_desc(dev,
|
||||||
&btns_desc->package.elements[i],
|
&btns_desc->package.elements[i],
|
||||||
collection_uid,
|
collection_uid,
|
||||||
&button_info[btn]))
|
&button_info[btn])) {
|
||||||
return ERR_PTR(-ENODEV);
|
button_info = ERR_PTR(-ENODEV);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
kfree(buf.pointer);
|
||||||
return button_info;
|
return button_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue