ACPI: sysfs: Finish sysfs init when creating a table file fails
PATCH 1/1 ACPI: sysfs: Finish sysfs init when creating a table file fails
If creating the file for a table fails, acpi_tables_sysfs_init() returns without sending the uevents for the tables directories, and acpi_sysfs_init() returns before creating the hotplug and pm_profile files.
Stop creating table files at that point, but finish the rest of the initialization. Skipping only the failed table would give its file name to the next table with the same signature, so reading that file would return the failed table.
---
This was noted in the review of the BDAT v1 patch:
https://lore.kernel.org/r/CAJZ5v0hM+6RvyXwG89Jyyu48jxSejNwsDt-H=2Y2dkt--af2QA@mail.gmail.com.
Handling it as a standalone patch here.
Tested on an arm64 server with test-only changes that make creating one table's file fail at boot (FPDT, or the second SSDT). Without this patch, pm_profile and hotplug are missing. With it, they are created, and every table file created before the failure matches a normal boot.
drivers/acpi/sysfs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/acpi/sysfs.c +3 -6
@@ -510,7 +510,6 @@ static int acpi_tables_sysfs_init(void)struct acpi_table_header *table_header =NULL ;int table_index;acpi_status status; -int ret; tables_kobj =kobject_create_and_add ("tables" , acpi_kobj);if (!tables_kobj)
@@ -535,13 +534,11 @@ static int acpi_tables_sysfs_init(void) table_attr =kzalloc_obj (*table_attr);if (!table_attr) -return -ENOMEM ; +break ; - ret =acpi_table_attr_init (tables_kobj, - table_attr, table_header); -if (ret) { +if (acpi_table_attr_init (tables_kobj, table_attr, table_header)) {kfree (table_attr); -return ret; +break ; }list_add_tail (&table_attr->node, &acpi_table_attr_list);acpi_table_data_init (table_header, table_attr);
Signature · 1 line
2.43.0
Rafael J. Wysocki (Intel)
maintainerQuoted 46 lines · Jamie Nguyen
If creating the file for a table fails,
acpi_tables_sysfs_init()returns without sending the uevents for the tables directories, andacpi_sysfs_init()returns before creating the hotplug andpm_profilefiles.Stop creating table files at that point, but finish the rest of the initialization. Skipping only the failed table would give its file name to the next table with the same signature, so reading that file would return the failed table.
Assisted-by LLMSigned-off-by Jamie Nguyen <[email protected]>---
This was noted in the review of the BDAT v1 patch:
https://lore.kernel.org/r/CAJZ5v0hM+6RvyXwG89Jyyu48jxSejNwsDt-H=2Y2dkt--af2QA@mail.gmail.com.
Handling it as a standalone patch here.Tested on an arm64 server with test-only changes that make creating one table's file fail at boot (FPDT, or the second SSDT). Without this patch,
pm_profileand hotplug are missing. With it, they are created, and every table file created before the failure matches a normal boot.drivers/acpi/sysfs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/acpi/sysfs.c +1
-3@@ -510,7 +510,6 @@ static int acpi_tables_sysfs_init(void)struct acpi_table_header *table_header =NULL ;int table_index;acpi_status status; -int ret; tables_kobj =kobject_create_and_add ("tables" , acpi_kobj);if (!tables_kobj)@@ -535,13 +534,11 @@ static int acpi_tables_sysfs_init(void) table_attr =kzalloc_obj (*table_attr);if (!table_attr) -return -ENOMEM ; +break ; - ret = acpi_table_attr_init(tables_kobj,
drivers/acpi/sysfs.c static int acpi_tables_sysfs_init(void)
Quoted 10 lines
drivers/acpi/sysfs.c +2
-4- table_attr, table_header); -if (ret) { +if (acpi_table_attr_init (tables_kobj, table_attr, table_header)) {kfree (table_attr); -return ret; +break ; }list_add_tail (&table_attr->node, &acpi_table_attr_list);acpi_table_data_init (table_header, table_attr); --
Sashiko has some feedback on this:
https://sashiko.dev/#/patchset/20261013193900.1258808-1-jamien%40nvidia.com
but that's about a pre-existing issue AFAICS, so applied as 7.4-rc material.
Thanks!