Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI: configfs: add missing check after configfs_register_default_group()

A list_add corruption is reported by Hulk Robot like this:
==============
list_add corruption.
Call Trace:
link_obj+0xc0/0x1c0
link_group+0x21/0x140
configfs_register_subsystem+0xdb/0x380
acpi_configfs_init+0x25/0x1000 [acpi_configfs]
do_one_initcall+0x149/0x820
do_init_module+0x1ef/0x720
load_module+0x35c8/0x4380
__do_sys_finit_module+0x10d/0x1a0
do_syscall_64+0x34/0x80

It's because of the missing check after configfs_register_default_group,
where configfs_unregister_subsystem should be called once failure.

Fixes: 612bd01fc6e0 ("ACPI: add support for loading SSDTs via configfs")
Reported-by: Hulk Robot <hulkci@huawei.com>
Suggested-by: Hanjun Guo <guohanjun@huawei.com>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
Cc: 4.10+ <stable@vger.kernel.org> # 4.10+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Qinglang Miao and committed by
Rafael J. Wysocki
67e40054 19c329f6

+6 -1
+6 -1
drivers/acpi/acpi_configfs.c
··· 268 268 269 269 acpi_table_group = configfs_register_default_group(root, "table", 270 270 &acpi_tables_type); 271 - return PTR_ERR_OR_ZERO(acpi_table_group); 271 + if (IS_ERR(acpi_table_group)) { 272 + configfs_unregister_subsystem(&acpi_configfs); 273 + return PTR_ERR(acpi_table_group); 274 + } 275 + 276 + return 0; 272 277 } 273 278 module_init(acpi_configfs_init); 274 279