diff options
| author | Denis V. Lunev <den@openvz.org> | 2008-04-29 04:02:27 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:22 -0400 |
| commit | cf7acfab032ff262f42954328cdfd20a5d9aaaac (patch) | |
| tree | 231698d72d4508f3b26f606f18ef844387ec43e5 /drivers/acpi/power.c | |
| parent | 667471386d4068e75a6a55b615701ced61eb6333 (diff) | |
acpi: use non-racy method for proc entries creation
Use proc_create()/proc_create_data() to make sure that ->proc_fops and ->data
be setup before gluing PDE to main tree.
Add correct ->owner to proc_fops to fix reading/module unloading race.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Cc: Len Brown <lenb@kernel.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/acpi/power.c')
| -rw-r--r-- | drivers/acpi/power.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 76bf6d90c70..21fc8bf0d31 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c | |||
| @@ -93,6 +93,7 @@ struct acpi_power_resource { | |||
| 93 | static struct list_head acpi_power_resource_list; | 93 | static struct list_head acpi_power_resource_list; |
| 94 | 94 | ||
| 95 | static const struct file_operations acpi_power_fops = { | 95 | static const struct file_operations acpi_power_fops = { |
| 96 | .owner = THIS_MODULE, | ||
| 96 | .open = acpi_power_open_fs, | 97 | .open = acpi_power_open_fs, |
| 97 | .read = seq_read, | 98 | .read = seq_read, |
| 98 | .llseek = seq_lseek, | 99 | .llseek = seq_lseek, |
| @@ -543,15 +544,11 @@ static int acpi_power_add_fs(struct acpi_device *device) | |||
| 543 | } | 544 | } |
| 544 | 545 | ||
| 545 | /* 'status' [R] */ | 546 | /* 'status' [R] */ |
| 546 | entry = create_proc_entry(ACPI_POWER_FILE_STATUS, | 547 | entry = proc_create_data(ACPI_POWER_FILE_STATUS, |
| 547 | S_IRUGO, acpi_device_dir(device)); | 548 | S_IRUGO, acpi_device_dir(device), |
| 549 | &acpi_power_fops, acpi_driver_data(device)); | ||
| 548 | if (!entry) | 550 | if (!entry) |
| 549 | return -EIO; | 551 | return -EIO; |
| 550 | else { | ||
| 551 | entry->proc_fops = &acpi_power_fops; | ||
| 552 | entry->data = acpi_driver_data(device); | ||
| 553 | } | ||
| 554 | |||
| 555 | return 0; | 552 | return 0; |
| 556 | } | 553 | } |
| 557 | 554 | ||
