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>
This commit is contained in:
Denis V. Lunev
2008-04-29 01:02:27 -07:00
committed by Linus Torvalds
parent 667471386d
commit cf7acfab03
17 changed files with 162 additions and 264 deletions

View File

@ -112,6 +112,7 @@ static struct acpi_driver acpi_processor_driver = {
#define UNINSTALL_NOTIFY_HANDLER 2
static const struct file_operations acpi_processor_info_fops = {
.owner = THIS_MODULE,
.open = acpi_processor_info_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@ -326,40 +327,30 @@ static int acpi_processor_add_fs(struct acpi_device *device)
acpi_device_dir(device)->owner = THIS_MODULE;
/* 'info' [R] */
entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO,
S_IRUGO, acpi_device_dir(device));
entry = proc_create_data(ACPI_PROCESSOR_FILE_INFO,
S_IRUGO, acpi_device_dir(device),
&acpi_processor_info_fops,
acpi_driver_data(device));
if (!entry)
return -EIO;
else {
entry->proc_fops = &acpi_processor_info_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'throttling' [R/W] */
entry = create_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING,
S_IFREG | S_IRUGO | S_IWUSR,
acpi_device_dir(device));
entry = proc_create_data(ACPI_PROCESSOR_FILE_THROTTLING,
S_IFREG | S_IRUGO | S_IWUSR,
acpi_device_dir(device),
&acpi_processor_throttling_fops,
acpi_driver_data(device));
if (!entry)
return -EIO;
else {
entry->proc_fops = &acpi_processor_throttling_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'limit' [R/W] */
entry = create_proc_entry(ACPI_PROCESSOR_FILE_LIMIT,
S_IFREG | S_IRUGO | S_IWUSR,
acpi_device_dir(device));
entry = proc_create_data(ACPI_PROCESSOR_FILE_LIMIT,
S_IFREG | S_IRUGO | S_IWUSR,
acpi_device_dir(device),
&acpi_processor_limit_fops,
acpi_driver_data(device));
if (!entry)
return -EIO;
else {
entry->proc_fops = &acpi_processor_limit_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
return 0;
}