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/system.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/system.c')
-rw-r--r-- | drivers/acpi/system.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c index 4749f379a915..769f24855eb6 100644 --- a/drivers/acpi/system.c +++ b/drivers/acpi/system.c | |||
@@ -396,6 +396,7 @@ static int acpi_system_info_open_fs(struct inode *inode, struct file *file) | |||
396 | } | 396 | } |
397 | 397 | ||
398 | static const struct file_operations acpi_system_info_ops = { | 398 | static const struct file_operations acpi_system_info_ops = { |
399 | .owner = THIS_MODULE, | ||
399 | .open = acpi_system_info_open_fs, | 400 | .open = acpi_system_info_open_fs, |
400 | .read = seq_read, | 401 | .read = seq_read, |
401 | .llseek = seq_lseek, | 402 | .llseek = seq_lseek, |
@@ -406,6 +407,7 @@ static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t, | |||
406 | loff_t *); | 407 | loff_t *); |
407 | 408 | ||
408 | static const struct file_operations acpi_system_dsdt_ops = { | 409 | static const struct file_operations acpi_system_dsdt_ops = { |
410 | .owner = THIS_MODULE, | ||
409 | .read = acpi_system_read_dsdt, | 411 | .read = acpi_system_read_dsdt, |
410 | }; | 412 | }; |
411 | 413 | ||
@@ -430,6 +432,7 @@ static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t, | |||
430 | loff_t *); | 432 | loff_t *); |
431 | 433 | ||
432 | static const struct file_operations acpi_system_fadt_ops = { | 434 | static const struct file_operations acpi_system_fadt_ops = { |
435 | .owner = THIS_MODULE, | ||
433 | .read = acpi_system_read_fadt, | 436 | .read = acpi_system_read_fadt, |
434 | }; | 437 | }; |
435 | 438 | ||
@@ -454,31 +457,23 @@ static int acpi_system_procfs_init(void) | |||
454 | { | 457 | { |
455 | struct proc_dir_entry *entry; | 458 | struct proc_dir_entry *entry; |
456 | int error = 0; | 459 | int error = 0; |
457 | char *name; | ||
458 | 460 | ||
459 | /* 'info' [R] */ | 461 | /* 'info' [R] */ |
460 | name = ACPI_SYSTEM_FILE_INFO; | 462 | entry = proc_create(ACPI_SYSTEM_FILE_INFO, S_IRUGO, acpi_root_dir, |
461 | entry = create_proc_entry(name, S_IRUGO, acpi_root_dir); | 463 | &acpi_system_info_ops); |
462 | if (!entry) | 464 | if (!entry) |
463 | goto Error; | 465 | goto Error; |
464 | else { | ||
465 | entry->proc_fops = &acpi_system_info_ops; | ||
466 | } | ||
467 | 466 | ||
468 | /* 'dsdt' [R] */ | 467 | /* 'dsdt' [R] */ |
469 | name = ACPI_SYSTEM_FILE_DSDT; | 468 | entry = proc_create(ACPI_SYSTEM_FILE_DSDT, S_IRUSR, acpi_root_dir, |
470 | entry = create_proc_entry(name, S_IRUSR, acpi_root_dir); | 469 | &acpi_system_dsdt_ops); |
471 | if (entry) | 470 | if (!entry) |
472 | entry->proc_fops = &acpi_system_dsdt_ops; | ||
473 | else | ||
474 | goto Error; | 471 | goto Error; |
475 | 472 | ||
476 | /* 'fadt' [R] */ | 473 | /* 'fadt' [R] */ |
477 | name = ACPI_SYSTEM_FILE_FADT; | 474 | entry = proc_create(ACPI_SYSTEM_FILE_FADT, S_IRUSR, acpi_root_dir, |
478 | entry = create_proc_entry(name, S_IRUSR, acpi_root_dir); | 475 | &acpi_system_fadt_ops); |
479 | if (entry) | 476 | if (!entry) |
480 | entry->proc_fops = &acpi_system_fadt_ops; | ||
481 | else | ||
482 | goto Error; | 477 | goto Error; |
483 | 478 | ||
484 | Done: | 479 | Done: |