From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Bob Moore <robert.moore@intel.com>,
Saket Dumbre <saket.dumbre@intel.com>
Subject: [PATCH v1 11/20] ACPICA: Fix memory leak if acpi_ps_get_next_field() fails
Date: Thu, 29 Aug 2024 20:36:45 +0200 [thread overview]
Message-ID: <8467075.NyiUUSuA9g@rjwysocki.net> (raw)
In-Reply-To: <5819337.DvuYhMxLoT@rjwysocki.net>
From: Armin Wolf <W_Armin@gmx.de>
ACPICA commit 1280045754264841b119a5ede96cd005bc09b5a7
If acpi_ps_get_next_field() fails, the previously created field list
needs to be properly disposed before returning the status code.
Link: https://github.com/acpica/acpica/commit/12800457
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
[ rjw: Rename local variable to avoid compiler confusion ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpica/psargs.c | 39 ++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c
index 7debfd5ce0d8..28582adfc0ac 100644
--- a/drivers/acpi/acpica/psargs.c
+++ b/drivers/acpi/acpica/psargs.c
@@ -25,6 +25,8 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state);
static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
*parser_state);
+static void acpi_ps_free_field_list(union acpi_parse_object *start);
+
/*******************************************************************************
*
* FUNCTION: acpi_ps_get_next_package_length
@@ -683,6 +685,39 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
return_PTR(field);
}
+/*******************************************************************************
+ *
+ * FUNCTION: acpi_ps_free_field_list
+ *
+ * PARAMETERS: start - First Op in field list
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Free all Op objects inside a field list.
+ *
+ ******************************************************************************/
+
+static void acpi_ps_free_field_list(union acpi_parse_object *start)
+{
+ union acpi_parse_object *cur = start;
+ union acpi_parse_object *next;
+ union acpi_parse_object *arg;
+
+ while (cur) {
+ next = cur->common.next;
+
+ /* AML_INT_CONNECTION_OP can have a single argument */
+
+ arg = acpi_ps_get_arg(cur, 0);
+ if (arg) {
+ acpi_ps_free_op(arg);
+ }
+
+ acpi_ps_free_op(cur);
+ cur = next;
+ }
+}
+
/*******************************************************************************
*
* FUNCTION: acpi_ps_get_next_arg
@@ -751,6 +786,10 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
while (parser_state->aml < parser_state->pkg_end) {
field = acpi_ps_get_next_field(parser_state);
if (!field) {
+ if (arg) {
+ acpi_ps_free_field_list(arg);
+ }
+
return_ACPI_STATUS(AE_NO_MEMORY);
}
--
2.43.0
next prev parent reply other threads:[~2024-08-29 18:44 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-29 18:18 [PATCH v1 00/20] ACPICA: Release 20240827 Rafael J. Wysocki
2024-08-29 18:21 ` [PATCH v1 01/20] ACPICA: haiku: Fix invalid value used for semaphores Rafael J. Wysocki
2024-08-29 18:22 ` [PATCH v1 02/20] ACPICA: Complete CXL 3.0 CXIMS structures Rafael J. Wysocki
2024-08-29 18:27 ` [PATCH v1 03/20] ACPICA: SPCR: Update the SPCR table to version 4 Rafael J. Wysocki
2024-08-29 18:28 ` [PATCH v1 04/20] ACPICA: Headers: Add RISC-V SBI Subtype to DBG2 Rafael J. Wysocki
2024-08-29 18:29 ` [PATCH v1 05/20] ACPICA: Implement the Dword_PCC Resource Descriptor Macro Rafael J. Wysocki
2024-08-29 18:30 ` [PATCH v1 06/20] ACPICA: MPAM: Correct the typo in struct acpi_mpam_msc_node member Rafael J. Wysocki
2024-08-29 18:31 ` [PATCH v1 07/20] ACPICA: Implement ACPI_WARNING_ONCE and ACPI_ERROR_ONCE Rafael J. Wysocki
2024-08-29 18:32 ` [PATCH v1 08/20] ACPICA: executer/exsystem: Don't nag user about every Stall() violating the spec Rafael J. Wysocki
2024-08-29 18:34 ` [PATCH v1 09/20] ACPICA: Allow PCC Data Type in MCTP resource Rafael J. Wysocki
2024-08-29 18:35 ` [PATCH v1 10/20] ACPICA: Fix memory leak if acpi_ps_get_next_namepath() fails Rafael J. Wysocki
2024-08-29 18:36 ` Rafael J. Wysocki [this message]
2024-08-29 18:37 ` [PATCH v1 12/20] ACPICA: Allow for supressing leading zeros when using acpi_ex_convert_to_ascii() Rafael J. Wysocki
2024-08-29 18:38 ` [PATCH v1 13/20] ACPICA: Add support for supressing leading zeros in hex strings Rafael J. Wysocki
2024-08-29 18:39 ` [PATCH v1 14/20] ACPICA: Update integer-to-hex-string conversions Rafael J. Wysocki
2024-08-29 18:40 ` [PATCH v1 15/20] ACPICA: Add support for Windows 11 22H2 _OSI string Rafael J. Wysocki
2024-08-29 18:41 ` [PATCH v1 16/20] ACPICA: Avoid warning for Dump Functions Rafael J. Wysocki
2024-08-29 18:41 ` [PATCH v1 17/20] ACPICA: HMAT: Add extended linear address mode to MSCIS Rafael J. Wysocki
2024-08-29 18:42 ` [PATCH v1 18/20] ACPICA: iasl: handle empty connection_node Rafael J. Wysocki
2024-08-29 18:43 ` [PATCH v1 19/20] ACPICA: Allow for more flexibility in _DSM args Rafael J. Wysocki
2024-08-29 18:44 ` [PATCH v1 20/20] ACPICA: Setup for ACPICA release 20240827 Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8467075.NyiUUSuA9g@rjwysocki.net \
--to=rjw@rjwysocki.net \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robert.moore@intel.com \
--cc=saket.dumbre@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®