mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jamie Nguyen <jamien@nvidia.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Len Brown <lenb@kernel.org>, <linux-acpi@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH] ACPI: sysfs: Release the table references taken during init
Date: Tue, 10 Nov 2026 14:54:52 -0800	[thread overview]
Message-ID: <20261110225452.2349540-1-jamien@nvidia.com> (raw)

acpi_tables_sysfs_init() gets each table with acpi_get_table_by_index()
to create its file, and acpi_table_attr_init() gets the second instance
of the table's signature with acpi_get_table() to decide whether the
file name needs an instance number. Neither reference is ever released,
so every table stays mapped. The file's read handler already gets and
puts the table on each read.

Release both references once the table is no longer used.

Fixes: 174cc7187e6f ("ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel")
Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
---
Sashiko flagged this, as a pre-existing issue, in its review of a
previous patch that I sent:
https://sashiko.dev/#/patchset/20261013193900.1258808-1-jamien%40nvidia.com

With the references released, a table that nothing else holds is
unmapped after init, and each read of its file maps it again
(acpi_table_show() already gets and puts the table).

Tested on an arm64 server and in QEMU (x86_64), with a test-only change
that prints each table's validation count after boot:
- Every table's count is one lower, and the second SSDT's is two lower,
  since the instance check in acpi_table_attr_init() also held it.
- All table files read back the same as without the patch, and
  repeated and parallel reads leave the counts unchanged.
- The BERT and BDAT data files still match /dev/mem.
- Loading and unloading SSDTs through ACPI configfs still works (QEMU).

 drivers/acpi/sysfs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index 49a820b39c2917a..d1b57d1246aafb1 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -372,6 +372,7 @@ static int acpi_table_attr_init(struct kobject *tables_obj,
 			 table_attr->instance);
 		strcat(table_attr->filename, instance_str);
 	}
+	acpi_put_table(header);
 
 	table_attr->attr.size = table_header->length;
 	table_attr->attr.read = acpi_table_show;
@@ -593,15 +594,19 @@ static int acpi_tables_sysfs_init(void)
 			continue;
 
 		table_attr = kzalloc_obj(*table_attr);
-		if (!table_attr)
+		if (!table_attr) {
+			acpi_put_table(table_header);
 			break;
+		}
 
 		if (acpi_table_attr_init(tables_kobj, table_attr, table_header)) {
 			kfree(table_attr);
+			acpi_put_table(table_header);
 			break;
 		}
 		list_add_tail(&table_attr->node, &acpi_table_attr_list);
 		acpi_table_data_init(table_header, table_attr);
+		acpi_put_table(table_header);
 	}
 
 	kobject_uevent(tables_kobj, KOBJ_ADD);

base-commit: 39e3c82b333ee534b6c41cc0e07364d78bea0ba9
-- 
2.43.0


                 reply	other threads:[~2026-11-10 22:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261110225452.2349540-1-jamien@nvidia.com \
    --to=jamien@nvidia.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@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 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®