diff options
author | Lv Zheng <lv.zheng@intel.com> | 2014-04-04 00:38:35 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-04-20 16:59:38 -0400 |
commit | 55df23f0d620c5194ecbd3b68ecdb2798778bf93 (patch) | |
tree | 22d088acce0e908142f0d8bef2323849f192677f /drivers/acpi/acpica | |
parent | dc156adf0d1b9d9ea54a86ca803ac5202ab139c7 (diff) |
ACPICA: Tables: Fix multiple ACPI_FREE()s around acpi_tb_add_table().
Currently there are following issues in acpi_tb_add_table():
Following logic is currently correct:
1. When a table is allocated in acpi_ex_load_op(), if a reloading happens,
the allocated memory is freed by acpi_tb_add_table() and AE_OK is
returned to the caller to avoid the caller to free it again.
Following logic is currently incorrect:
1. When a table is allocated in acpi_ex_load_op() or by the
acpi_load_table() caller, if the table is already loaded, there will be
twice ACPI_FREE() called for the same pointer when acpi_tb_add_table()
returns AE_ALREADY_EXISTS.
This patch only fixes the above incorrect logic in acpi_tb_add_table():
1. Only invoke acpi_tb_delete_table() if AE_OK is going to be returned.
2. After doing so, we do not invoke ACPI_FREE() when returning AE_OK;
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
[rjw: Subject]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/acpica')
-rw-r--r-- | drivers/acpi/acpica/exconfig.c | 2 | ||||
-rw-r--r-- | drivers/acpi/acpica/tbinstal.c | 7 |
2 files changed, 2 insertions, 7 deletions
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c index 649a8efef0f5..11a014ca3935 100644 --- a/drivers/acpi/acpica/exconfig.c +++ b/drivers/acpi/acpica/exconfig.c | |||
@@ -504,7 +504,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc, | |||
504 | 504 | ||
505 | /* Delete allocated table buffer */ | 505 | /* Delete allocated table buffer */ |
506 | 506 | ||
507 | acpi_tb_delete_table(&table_desc); | 507 | ACPI_FREE(table_desc.pointer); |
508 | return_ACPI_STATUS(status); | 508 | return_ACPI_STATUS(status); |
509 | } | 509 | } |
510 | 510 | ||
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c index 144076ac21f0..0040e19b6d14 100644 --- a/drivers/acpi/acpica/tbinstal.c +++ b/drivers/acpi/acpica/tbinstal.c | |||
@@ -203,12 +203,6 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) | |||
203 | * need to be unregistered when they are unloaded, and slots in the | 203 | * need to be unregistered when they are unloaded, and slots in the |
204 | * root table list should be reused when empty. | 204 | * root table list should be reused when empty. |
205 | */ | 205 | */ |
206 | |||
207 | /* | ||
208 | * Table is already registered. | ||
209 | * We can delete the table that was passed as a parameter. | ||
210 | */ | ||
211 | acpi_tb_delete_table(table_desc); | ||
212 | *table_index = i; | 206 | *table_index = i; |
213 | 207 | ||
214 | if (acpi_gbl_root_table_list.tables[i]. | 208 | if (acpi_gbl_root_table_list.tables[i]. |
@@ -221,6 +215,7 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) | |||
221 | } else { | 215 | } else { |
222 | /* Table was unloaded, allow it to be reloaded */ | 216 | /* Table was unloaded, allow it to be reloaded */ |
223 | 217 | ||
218 | acpi_tb_delete_table(table_desc); | ||
224 | table_desc->pointer = | 219 | table_desc->pointer = |
225 | acpi_gbl_root_table_list.tables[i].pointer; | 220 | acpi_gbl_root_table_list.tables[i].pointer; |
226 | table_desc->address = | 221 | table_desc->address = |