| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * custom_method.c - debugfs interface for customizing ACPI control method |
|---|
| 3 | 4 | */ |
|---|
| .. | .. |
|---|
| 8 | 9 | #include <linux/uaccess.h> |
|---|
| 9 | 10 | #include <linux/debugfs.h> |
|---|
| 10 | 11 | #include <linux/acpi.h> |
|---|
| 12 | +#include <linux/security.h> |
|---|
| 11 | 13 | |
|---|
| 12 | 14 | #include "internal.h" |
|---|
| 13 | 15 | |
|---|
| 14 | | -#define _COMPONENT ACPI_SYSTEM_COMPONENT |
|---|
| 15 | | -ACPI_MODULE_NAME("custom_method"); |
|---|
| 16 | 16 | MODULE_LICENSE("GPL"); |
|---|
| 17 | 17 | |
|---|
| 18 | 18 | static struct dentry *cm_dentry; |
|---|
| .. | .. |
|---|
| 28 | 28 | |
|---|
| 29 | 29 | struct acpi_table_header table; |
|---|
| 30 | 30 | acpi_status status; |
|---|
| 31 | + int ret; |
|---|
| 32 | + |
|---|
| 33 | + ret = security_locked_down(LOCKDOWN_ACPI_TABLES); |
|---|
| 34 | + if (ret) |
|---|
| 35 | + return ret; |
|---|
| 31 | 36 | |
|---|
| 32 | 37 | if (!(*ppos)) { |
|---|
| 33 | 38 | /* parse the table header to get the table length */ |
|---|
| .. | .. |
|---|
| 84 | 89 | |
|---|
| 85 | 90 | static int __init acpi_custom_method_init(void) |
|---|
| 86 | 91 | { |
|---|
| 87 | | - if (acpi_debugfs_dir == NULL) |
|---|
| 88 | | - return -ENOENT; |
|---|
| 89 | | - |
|---|
| 90 | 92 | cm_dentry = debugfs_create_file("custom_method", S_IWUSR, |
|---|
| 91 | 93 | acpi_debugfs_dir, NULL, &cm_fops); |
|---|
| 92 | | - if (cm_dentry == NULL) |
|---|
| 93 | | - return -ENODEV; |
|---|
| 94 | | - |
|---|
| 95 | 94 | return 0; |
|---|
| 96 | 95 | } |
|---|
| 97 | 96 | |
|---|
| 98 | 97 | static void __exit acpi_custom_method_exit(void) |
|---|
| 99 | 98 | { |
|---|
| 100 | | - if (cm_dentry) |
|---|
| 101 | | - debugfs_remove(cm_dentry); |
|---|
| 99 | + debugfs_remove(cm_dentry); |
|---|
| 102 | 100 | } |
|---|
| 103 | 101 | |
|---|
| 104 | 102 | module_init(acpi_custom_method_init); |
|---|