aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/processor_core.c
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2008-04-29 04:02:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:22 -0400
commitcf7acfab032ff262f42954328cdfd20a5d9aaaac (patch)
tree231698d72d4508f3b26f606f18ef844387ec43e5 /drivers/acpi/processor_core.c
parent667471386d4068e75a6a55b615701ced61eb6333 (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/processor_core.c')
-rw-r--r--drivers/acpi/processor_core.c39
1 files changed, 15 insertions, 24 deletions
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index a825b431b64f..dd28c912e84f 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -112,6 +112,7 @@ static struct acpi_driver acpi_processor_driver = {
112#define UNINSTALL_NOTIFY_HANDLER 2 112#define UNINSTALL_NOTIFY_HANDLER 2
113 113
114static const struct file_operations acpi_processor_info_fops = { 114static const struct file_operations acpi_processor_info_fops = {
115 .owner = THIS_MODULE,
115 .open = acpi_processor_info_open_fs, 116 .open = acpi_processor_info_open_fs,
116 .read = seq_read, 117 .read = seq_read,
117 .llseek = seq_lseek, 118 .llseek = seq_lseek,
@@ -326,40 +327,30 @@ static int acpi_processor_add_fs(struct acpi_device *device)
326 acpi_device_dir(device)->owner = THIS_MODULE; 327 acpi_device_dir(device)->owner = THIS_MODULE;
327 328
328 /* 'info' [R] */ 329 /* 'info' [R] */
329 entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO, 330 entry = proc_create_data(ACPI_PROCESSOR_FILE_INFO,
330 S_IRUGO, acpi_device_dir(device)); 331 S_IRUGO, acpi_device_dir(device),
332 &acpi_processor_info_fops,
333 acpi_driver_data(device));
331 if (!entry) 334 if (!entry)
332 return -EIO; 335 return -EIO;
333 else {
334 entry->proc_fops = &acpi_processor_info_fops;
335 entry->data = acpi_driver_data(device);
336 entry->owner = THIS_MODULE;
337 }
338 336
339 /* 'throttling' [R/W] */ 337 /* 'throttling' [R/W] */
340 entry = create_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING, 338 entry = proc_create_data(ACPI_PROCESSOR_FILE_THROTTLING,
341 S_IFREG | S_IRUGO | S_IWUSR, 339 S_IFREG | S_IRUGO | S_IWUSR,
342 acpi_device_dir(device)); 340 acpi_device_dir(device),
341 &acpi_processor_throttling_fops,
342 acpi_driver_data(device));
343 if (!entry) 343 if (!entry)
344 return -EIO; 344 return -EIO;
345 else {
346 entry->proc_fops = &acpi_processor_throttling_fops;
347 entry->data = acpi_driver_data(device);
348 entry->owner = THIS_MODULE;
349 }
350 345
351 /* 'limit' [R/W] */ 346 /* 'limit' [R/W] */
352 entry = create_proc_entry(ACPI_PROCESSOR_FILE_LIMIT, 347 entry = proc_create_data(ACPI_PROCESSOR_FILE_LIMIT,
353 S_IFREG | S_IRUGO | S_IWUSR, 348 S_IFREG | S_IRUGO | S_IWUSR,
354 acpi_device_dir(device)); 349 acpi_device_dir(device),
350 &acpi_processor_limit_fops,
351 acpi_driver_data(device));
355 if (!entry) 352 if (!entry)
356 return -EIO; 353 return -EIO;
357 else {
358 entry->proc_fops = &acpi_processor_limit_fops;
359 entry->data = acpi_driver_data(device);
360 entry->owner = THIS_MODULE;
361 }
362
363 return 0; 354 return 0;
364} 355}
365 356