* [PATCH] ACPICA: DEBUGGER: Add return value check to acpi_db_walk_for_fields()
@ 2021-12-29 17:40 shenzijun
2021-12-30 16:31 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: shenzijun @ 2021-12-29 17:40 UTC (permalink / raw)
To: robert.moore, rafael.j.wysocki, lenb
Cc: linux-acpi, devel, linux-kernel, jinzi120021
From: Zijun Shen <shenzijun@kylinos.cn>
The function acpi_db_walk_for_fields frees buffer.pointer by the
first ACPI_FREE. And then uses the second ACPI_FREE to free
buffer.pointer which may assigns again in acpi_evaluate_object.
It's necessary to make sure that buffer.pointer get a block of
memory in acpi_evaluate_object and acpi_evaluate_object return 0.
Signed-off-by: Zijun Shen <shenzijun@kylinos.cn>
---
drivers/acpi/acpica/dbnames.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/acpica/dbnames.c b/drivers/acpi/acpica/dbnames.c
index 3615e1a6efd8..7a2d980cb2b8 100644
--- a/drivers/acpi/acpica/dbnames.c
+++ b/drivers/acpi/acpica/dbnames.c
@@ -550,7 +550,10 @@ acpi_db_walk_for_fields(acpi_handle obj_handle,
ACPI_FREE(buffer.pointer);
buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
- acpi_evaluate_object(obj_handle, NULL, NULL, &buffer);
+ status = acpi_evaluate_object(obj_handle, NULL, NULL, &buffer);
+ if (ACPI_FAILURE(status)) {
+ return (AE_OK);
+ }
/*
* Since this is a field unit, surround the output in braces
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ACPICA: DEBUGGER: Add return value check to acpi_db_walk_for_fields()
2021-12-29 17:40 [PATCH] ACPICA: DEBUGGER: Add return value check to acpi_db_walk_for_fields() shenzijun
@ 2021-12-30 16:31 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2021-12-30 16:31 UTC (permalink / raw)
To: shenzijun
Cc: Robert Moore, Rafael Wysocki, Len Brown, ACPI Devel Maling List,
open list:ACPI COMPONENT ARCHITECTURE (ACPICA),
Linux Kernel Mailing List, jinzi120021
On Wed, Dec 29, 2021 at 10:41 AM shenzijun <shenzijun@kylinos.cn> wrote:
>
> From: Zijun Shen <shenzijun@kylinos.cn>
>
> The function acpi_db_walk_for_fields frees buffer.pointer by the
> first ACPI_FREE. And then uses the second ACPI_FREE to free
> buffer.pointer which may assigns again in acpi_evaluate_object.
> It's necessary to make sure that buffer.pointer get a block of
> memory in acpi_evaluate_object and acpi_evaluate_object return 0.
>
> Signed-off-by: Zijun Shen <shenzijun@kylinos.cn>
> ---
> drivers/acpi/acpica/dbnames.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/acpica/dbnames.c b/drivers/acpi/acpica/dbnames.c
> index 3615e1a6efd8..7a2d980cb2b8 100644
> --- a/drivers/acpi/acpica/dbnames.c
> +++ b/drivers/acpi/acpica/dbnames.c
> @@ -550,7 +550,10 @@ acpi_db_walk_for_fields(acpi_handle obj_handle,
> ACPI_FREE(buffer.pointer);
>
> buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
> - acpi_evaluate_object(obj_handle, NULL, NULL, &buffer);
> + status = acpi_evaluate_object(obj_handle, NULL, NULL, &buffer);
> + if (ACPI_FAILURE(status)) {
> + return (AE_OK);
> + }
>
> /*
> * Since this is a field unit, surround the output in braces
> --
This is ACPICA material, so please submit it to the upstream ACPICA
project via https://github.com/acpica/acpica/
Thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-30 16:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-29 17:40 [PATCH] ACPICA: DEBUGGER: Add return value check to acpi_db_walk_for_fields() shenzijun
2021-12-30 16:31 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).