All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Armin Wolf <W_Armin@gmx.de>
To: Dmitry Antipov <dmantipov@yandex.ru>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Cc: linux-acpi@vger.kernel.org
Subject: Re: ACPI BIOS bug and memory leak?
Date: Sun, 31 Mar 2024 04:46:33 +0200	[thread overview]
Message-ID: <cb9c17e4-53f0-4579-879a-0a8fa1352fb9@gmx.de> (raw)
In-Reply-To: <9d0a3bd8-62d6-43cc-8109-311448ad0867@yandex.ru>

[-- Attachment #1: Type: text/plain, Size: 2311 bytes --]

Am 27.03.24 um 11:48 schrieb Dmitry Antipov:

> Is it possible that this:
>
> [    7.727080] ACPI BIOS Error (bug): Could not resolve symbol
> [\_TZ.ETMD], AE_NOT_FOUND (20230628/psargs-335)
> [    7.728470] ACPI Error: Aborting method \_SB.IETM._OSC due to
> previous error (AE_NOT_FOUND) (20230628/psparse-529)
>
> is somehow related to:
>
> unreferenced object 0xffff944e85013d58 (size 56):
>   comm "thermald", pid 966, jiffies 4294674933
>   hex dump (first 32 bytes):
>     00 00 00 00 00 00 00 00 0d 01 2d 00 00 00 00 00 ..........-.....
>     94 8c 05 80 51 b8 ff ff 00 00 00 00 00 00 00 00 ....Q...........
>   backtrace (crc 41e9984d):
>     [<000000004b53f9d1>] kmem_cache_alloc+0x256/0x340
>     [<000000008d9ead3a>] acpi_ps_alloc_op+0xbf/0xd0
>     [<000000002f1e617e>] acpi_ps_get_next_arg+0xbb/0x6a0
>     [<00000000b697bac7>] acpi_ps_parse_loop+0x466/0x6b0
>     [<000000008dbc2acb>] acpi_ps_parse_aml+0x80/0x3c0
>     [<00000000b26066ae>] acpi_ps_execute_method+0x13f/0x270
>     [<00000000f80592ab>] acpi_ns_evaluate+0x12b/0x2c0
>     [<00000000bbc91886>] acpi_evaluate_object+0x14e/0x310
>     [<000000005729c43d>] acpi_run_osc+0x158/0x270
>     [<00000000e6666993>] int3400_thermal_run_osc+0x73/0xc0
> [int3400_thermal]
>     [<000000000a474314>] current_uuid_store+0xd5/0x110 [int3400_thermal]
>     [<00000000e27be786>] kernfs_fop_write_iter+0x13e/0x1f0
>     [<00000000992f9e08>] vfs_write+0x293/0x460
>     [<000000008b9e130c>] ksys_write+0x6d/0xf0
>     [<000000007d501d09>] do_syscall_64+0x85/0x170
>     [<0000000073c5a34b>] entry_SYSCALL_64_after_hwframe+0x6c/0x74
>
> (recently observed on 6.9.0-rc1)
>
> Dmitry
>
Hi,

i thing the memory leak happens in acpi_ps_get_next_arg(). After allocating an acpi_parse_object in line 820 of psargs.c,
calling of acpi_ps_get_next_namepath() fails due to to the missing symbol. The code now returns the error without freeing
the acpi_parse_object, causing a memory leak.

IMHO the solution would be to call acpi_ps_free_op() in case of an error before returning said error code. I attached an
experimental patch which might fix this, but it is still untested. If you want you can test if it solves the problem.

Thanks,
Armin Wolf

[-- Attachment #2: 0001-ACPICA-Fix-memory-leak-then-namespace-lookup-fails.patch --]
[-- Type: text/x-patch, Size: 1483 bytes --]

From 650c010ef7841bebbacc074f359909e84633b4f8 Mon Sep 17 00:00:00 2001
From: Armin Wolf <W_Armin@gmx.de>
Date: Sun, 31 Mar 2024 04:39:54 +0200
Subject: [PATCH] ACPICA: Fix memory leak then namespace lookup fails

When acpi_ps_get_next_namepath() fails due to a namespace lookup
failure, the acpi_parse_object is not freed before returning the
error code, casuing a memory leak.

Fix this by freeing the acpi_parse_object when encountering an
error.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/acpi/acpica/psargs.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c
index 422c074ed289..7debfd5ce0d8 100644
--- a/drivers/acpi/acpica/psargs.c
+++ b/drivers/acpi/acpica/psargs.c
@@ -820,6 +820,10 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
 			    acpi_ps_get_next_namepath(walk_state, parser_state,
 						      arg,
 						      ACPI_NOT_METHOD_CALL);
+			if (ACPI_FAILURE(status)) {
+				acpi_ps_free_op(arg);
+				return_ACPI_STATUS(status);
+			}
 		} else {
 			/* Single complex argument, nothing returned */
 
@@ -854,6 +858,10 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
 			    acpi_ps_get_next_namepath(walk_state, parser_state,
 						      arg,
 						      ACPI_POSSIBLE_METHOD_CALL);
+			if (ACPI_FAILURE(status)) {
+				acpi_ps_free_op(arg);
+				return_ACPI_STATUS(status);
+			}
 
 			if (arg->common.aml_opcode == AML_INT_METHODCALL_OP) {
 
-- 
2.39.2


  reply	other threads:[~2024-03-31  2:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-27 10:48 ACPI BIOS bug and memory leak? Dmitry Antipov
2024-03-31  2:46 ` Armin Wolf [this message]
2024-04-02 18:26   ` Dmitry Antipov

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=cb9c17e4-53f0-4579-879a-0a8fa1352fb9@gmx.de \
    --to=w_armin@gmx.de \
    --cc=dmantipov@yandex.ru \
    --cc=linux-acpi@vger.kernel.org \
    --cc=rafael@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.