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/sbs.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/sbs.c')
-rw-r--r-- | drivers/acpi/sbs.c | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index 585ae3c9c8ea..10a36512647c 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c | |||
@@ -483,8 +483,6 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir, | |||
483 | struct file_operations *state_fops, | 483 | struct file_operations *state_fops, |
484 | struct file_operations *alarm_fops, void *data) | 484 | struct file_operations *alarm_fops, void *data) |
485 | { | 485 | { |
486 | struct proc_dir_entry *entry = NULL; | ||
487 | |||
488 | if (!*dir) { | 486 | if (!*dir) { |
489 | *dir = proc_mkdir(dir_name, parent_dir); | 487 | *dir = proc_mkdir(dir_name, parent_dir); |
490 | if (!*dir) { | 488 | if (!*dir) { |
@@ -494,34 +492,19 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir, | |||
494 | } | 492 | } |
495 | 493 | ||
496 | /* 'info' [R] */ | 494 | /* 'info' [R] */ |
497 | if (info_fops) { | 495 | if (info_fops) |
498 | entry = create_proc_entry(ACPI_SBS_FILE_INFO, S_IRUGO, *dir); | 496 | proc_create_data(ACPI_SBS_FILE_INFO, S_IRUGO, *dir, |
499 | if (entry) { | 497 | info_fops, data); |
500 | entry->proc_fops = info_fops; | ||
501 | entry->data = data; | ||
502 | entry->owner = THIS_MODULE; | ||
503 | } | ||
504 | } | ||
505 | 498 | ||
506 | /* 'state' [R] */ | 499 | /* 'state' [R] */ |
507 | if (state_fops) { | 500 | if (state_fops) |
508 | entry = create_proc_entry(ACPI_SBS_FILE_STATE, S_IRUGO, *dir); | 501 | proc_create_data(ACPI_SBS_FILE_STATE, S_IRUGO, *dir, |
509 | if (entry) { | 502 | state_fops, data); |
510 | entry->proc_fops = state_fops; | ||
511 | entry->data = data; | ||
512 | entry->owner = THIS_MODULE; | ||
513 | } | ||
514 | } | ||
515 | 503 | ||
516 | /* 'alarm' [R/W] */ | 504 | /* 'alarm' [R/W] */ |
517 | if (alarm_fops) { | 505 | if (alarm_fops) |
518 | entry = create_proc_entry(ACPI_SBS_FILE_ALARM, S_IRUGO, *dir); | 506 | proc_create_data(ACPI_SBS_FILE_ALARM, S_IRUGO, *dir, |
519 | if (entry) { | 507 | alarm_fops, data); |
520 | entry->proc_fops = alarm_fops; | ||
521 | entry->data = data; | ||
522 | entry->owner = THIS_MODULE; | ||
523 | } | ||
524 | } | ||
525 | return 0; | 508 | return 0; |
526 | } | 509 | } |
527 | 510 | ||