Commit 46922d2a authored by Lv Zheng's avatar Lv Zheng Committed by Rafael J. Wysocki

ACPI / EC: Fix a memory leakage issue in acpi_ec_add()

When the handler installation failed, there was no code to free the
allocated EC device. This patch fixes this memory leakage issue.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=115021Reported-and-tested-by: default avatarLuya Tshimbalanga <luya@fedoraproject.org>
Tested-by: default avatarJonh Henderson <jw.hendy@gmail.com>
Signed-off-by: default avatarLv Zheng <lv.zheng@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 72c77b7e
...@@ -1513,14 +1513,18 @@ static int acpi_ec_add(struct acpi_device *device) ...@@ -1513,14 +1513,18 @@ static int acpi_ec_add(struct acpi_device *device)
return -ENOMEM; return -ENOMEM;
if (ec_parse_device(device->handle, 0, ec, NULL) != if (ec_parse_device(device->handle, 0, ec, NULL) !=
AE_CTRL_TERMINATE) { AE_CTRL_TERMINATE) {
acpi_ec_free(ec); ret = -EINVAL;
return -EINVAL; goto err_alloc;
} }
/* Find and register all query methods */ /* Find and register all query methods */
acpi_walk_namespace(ACPI_TYPE_METHOD, ec->handle, 1, acpi_walk_namespace(ACPI_TYPE_METHOD, ec->handle, 1,
acpi_ec_register_query_methods, NULL, ec, NULL); acpi_ec_register_query_methods, NULL, ec, NULL);
ret = acpi_config_boot_ec(ec, false);
if (ret)
goto err_query;
device->driver_data = ec; device->driver_data = ec;
ret = !!request_region(ec->data_addr, 1, "EC data"); ret = !!request_region(ec->data_addr, 1, "EC data");
...@@ -1528,13 +1532,17 @@ static int acpi_ec_add(struct acpi_device *device) ...@@ -1528,13 +1532,17 @@ static int acpi_ec_add(struct acpi_device *device)
ret = !!request_region(ec->command_addr, 1, "EC cmd"); ret = !!request_region(ec->command_addr, 1, "EC cmd");
WARN(!ret, "Could not request EC cmd io port 0x%lx", ec->command_addr); WARN(!ret, "Could not request EC cmd io port 0x%lx", ec->command_addr);
ret = acpi_config_boot_ec(ec, false);
/* Reprobe devices depending on the EC */ /* Reprobe devices depending on the EC */
acpi_walk_dep_device_list(ec->handle); acpi_walk_dep_device_list(ec->handle);
/* EC is fully operational, allow queries */ /* EC is fully operational, allow queries */
acpi_ec_enable_event(ec); acpi_ec_enable_event(ec);
return 0;
err_query:
acpi_ec_remove_query_handlers(ec, true, 0);
err_alloc:
acpi_ec_free(ec);
return ret; return ret;
} }
......
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