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:
committed by
Linus Torvalds
parent
667471386d
commit
cf7acfab03
@@ -93,6 +93,7 @@ struct acpi_power_resource {
|
||||
static struct list_head acpi_power_resource_list;
|
||||
|
||||
static const struct file_operations acpi_power_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = acpi_power_open_fs,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
@@ -543,15 +544,11 @@ static int acpi_power_add_fs(struct acpi_device *device)
|
||||
}
|
||||
|
||||
/* 'status' [R] */
|
||||
entry = create_proc_entry(ACPI_POWER_FILE_STATUS,
|
||||
S_IRUGO, acpi_device_dir(device));
|
||||
entry = proc_create_data(ACPI_POWER_FILE_STATUS,
|
||||
S_IRUGO, acpi_device_dir(device),
|
||||
&acpi_power_fops, acpi_driver_data(device));
|
||||
if (!entry)
|
||||
return -EIO;
|
||||
else {
|
||||
entry->proc_fops = &acpi_power_fops;
|
||||
entry->data = acpi_driver_data(device);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user