mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
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:
parent
667471386d
commit
cf7acfab03
17 changed files with 162 additions and 264 deletions
|
@ -411,6 +411,7 @@ EXPORT_SYMBOL(acpi_processor_notify_smm);
|
|||
|
||||
static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file);
|
||||
static struct file_operations acpi_processor_perf_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = acpi_processor_perf_open_fs,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
|
@ -456,7 +457,6 @@ static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file)
|
|||
|
||||
static void acpi_cpufreq_add_file(struct acpi_processor *pr)
|
||||
{
|
||||
struct proc_dir_entry *entry = NULL;
|
||||
struct acpi_device *device = NULL;
|
||||
|
||||
|
||||
|
@ -464,14 +464,9 @@ static void acpi_cpufreq_add_file(struct acpi_processor *pr)
|
|||
return;
|
||||
|
||||
/* add file 'performance' [R/W] */
|
||||
entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
|
||||
S_IFREG | S_IRUGO,
|
||||
acpi_device_dir(device));
|
||||
if (entry){
|
||||
entry->proc_fops = &acpi_processor_perf_fops;
|
||||
entry->data = acpi_driver_data(device);
|
||||
entry->owner = THIS_MODULE;
|
||||
}
|
||||
proc_create_data(ACPI_PROCESSOR_FILE_PERFORMANCE, S_IFREG | S_IRUGO,
|
||||
acpi_device_dir(device),
|
||||
&acpi_processor_perf_fops, acpi_driver_data(device));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue