aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2008-04-29 04:02:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:22 -0400
commitac41cfd19bf77424519b962f8205ede51fceaac6 (patch)
treef0299767b2115dd076e01841ca5cbe3113ef7a02 /drivers
parenta95609cb0283a23e519e607ff9fc2a4aa77e2532 (diff)
isdn: 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> Acked-by: Karsten Keil <kkeil@suse.de> 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')
-rw-r--r--drivers/isdn/capi/kcapi_proc.c24
-rw-r--r--drivers/isdn/divert/divert_procfs.c5
-rw-r--r--drivers/isdn/hardware/eicon/divasproc.c8
-rw-r--r--drivers/isdn/hysdn/hysdn_procconf.c9
-rw-r--r--drivers/isdn/hysdn/hysdn_proclog.c8
5 files changed, 22 insertions, 32 deletions
diff --git a/drivers/isdn/capi/kcapi_proc.c b/drivers/isdn/capi/kcapi_proc.c
index 845a797b0030..c29208bd7521 100644
--- a/drivers/isdn/capi/kcapi_proc.c
+++ b/drivers/isdn/capi/kcapi_proc.c
@@ -114,6 +114,7 @@ static int seq_contrstats_open(struct inode *inode, struct file *file)
114} 114}
115 115
116static const struct file_operations proc_controller_ops = { 116static const struct file_operations proc_controller_ops = {
117 .owner = THIS_MODULE,
117 .open = seq_controller_open, 118 .open = seq_controller_open,
118 .read = seq_read, 119 .read = seq_read,
119 .llseek = seq_lseek, 120 .llseek = seq_lseek,
@@ -121,6 +122,7 @@ static const struct file_operations proc_controller_ops = {
121}; 122};
122 123
123static const struct file_operations proc_contrstats_ops = { 124static const struct file_operations proc_contrstats_ops = {
125 .owner = THIS_MODULE,
124 .open = seq_contrstats_open, 126 .open = seq_contrstats_open,
125 .read = seq_read, 127 .read = seq_read,
126 .llseek = seq_lseek, 128 .llseek = seq_lseek,
@@ -219,6 +221,7 @@ seq_applstats_open(struct inode *inode, struct file *file)
219} 221}
220 222
221static const struct file_operations proc_applications_ops = { 223static const struct file_operations proc_applications_ops = {
224 .owner = THIS_MODULE,
222 .open = seq_applications_open, 225 .open = seq_applications_open,
223 .read = seq_read, 226 .read = seq_read,
224 .llseek = seq_lseek, 227 .llseek = seq_lseek,
@@ -226,21 +229,13 @@ static const struct file_operations proc_applications_ops = {
226}; 229};
227 230
228static const struct file_operations proc_applstats_ops = { 231static const struct file_operations proc_applstats_ops = {
232 .owner = THIS_MODULE,
229 .open = seq_applstats_open, 233 .open = seq_applstats_open,
230 .read = seq_read, 234 .read = seq_read,
231 .llseek = seq_lseek, 235 .llseek = seq_lseek,
232 .release = seq_release, 236 .release = seq_release,
233}; 237};
234 238
235static void
236create_seq_entry(char *name, mode_t mode, const struct file_operations *f)
237{
238 struct proc_dir_entry *entry;
239 entry = create_proc_entry(name, mode, NULL);
240 if (entry)
241 entry->proc_fops = f;
242}
243
244// --------------------------------------------------------------------------- 239// ---------------------------------------------------------------------------
245 240
246static void *capi_driver_start(struct seq_file *seq, loff_t *pos) 241static void *capi_driver_start(struct seq_file *seq, loff_t *pos)
@@ -283,6 +278,7 @@ seq_capi_driver_open(struct inode *inode, struct file *file)
283} 278}
284 279
285static const struct file_operations proc_driver_ops = { 280static const struct file_operations proc_driver_ops = {
281 .owner = THIS_MODULE,
286 .open = seq_capi_driver_open, 282 .open = seq_capi_driver_open,
287 .read = seq_read, 283 .read = seq_read,
288 .llseek = seq_lseek, 284 .llseek = seq_lseek,
@@ -296,11 +292,11 @@ kcapi_proc_init(void)
296{ 292{
297 proc_mkdir("capi", NULL); 293 proc_mkdir("capi", NULL);
298 proc_mkdir("capi/controllers", NULL); 294 proc_mkdir("capi/controllers", NULL);
299 create_seq_entry("capi/controller", 0, &proc_controller_ops); 295 proc_create("capi/controller", 0, NULL, &proc_controller_ops);
300 create_seq_entry("capi/contrstats", 0, &proc_contrstats_ops); 296 proc_create("capi/contrstats", 0, NULL, &proc_contrstats_ops);
301 create_seq_entry("capi/applications", 0, &proc_applications_ops); 297 proc_create("capi/applications", 0, NULL, &proc_applications_ops);
302 create_seq_entry("capi/applstats", 0, &proc_applstats_ops); 298 proc_create("capi/applstats", 0, NULL, &proc_applstats_ops);
303 create_seq_entry("capi/driver", 0, &proc_driver_ops); 299 proc_create("capi/driver", 0, NULL, &proc_driver_ops);
304} 300}
305 301
306void __exit 302void __exit
diff --git a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c
index 4fd4c46892e3..8b256a617c8a 100644
--- a/drivers/isdn/divert/divert_procfs.c
+++ b/drivers/isdn/divert/divert_procfs.c
@@ -288,13 +288,12 @@ divert_dev_init(void)
288 isdn_proc_entry = proc_mkdir("isdn", init_net.proc_net); 288 isdn_proc_entry = proc_mkdir("isdn", init_net.proc_net);
289 if (!isdn_proc_entry) 289 if (!isdn_proc_entry)
290 return (-1); 290 return (-1);
291 isdn_divert_entry = create_proc_entry("divert", S_IFREG | S_IRUGO, isdn_proc_entry); 291 isdn_divert_entry = proc_create("divert", S_IFREG | S_IRUGO,
292 isdn_proc_entry, &isdn_fops);
292 if (!isdn_divert_entry) { 293 if (!isdn_divert_entry) {
293 remove_proc_entry("isdn", init_net.proc_net); 294 remove_proc_entry("isdn", init_net.proc_net);
294 return (-1); 295 return (-1);
295 } 296 }
296 isdn_divert_entry->proc_fops = &isdn_fops;
297 isdn_divert_entry->owner = THIS_MODULE;
298#endif /* CONFIG_PROC_FS */ 297#endif /* CONFIG_PROC_FS */
299 298
300 return (0); 299 return (0);
diff --git a/drivers/isdn/hardware/eicon/divasproc.c b/drivers/isdn/hardware/eicon/divasproc.c
index 0632a2606998..fae895828a17 100644
--- a/drivers/isdn/hardware/eicon/divasproc.c
+++ b/drivers/isdn/hardware/eicon/divasproc.c
@@ -125,15 +125,11 @@ static const struct file_operations divas_fops = {
125 125
126int create_divas_proc(void) 126int create_divas_proc(void)
127{ 127{
128 divas_proc_entry = create_proc_entry(divas_proc_name, 128 proc_create(divas_proc_name, S_IFREG | S_IRUGO, proc_net_eicon,
129 S_IFREG | S_IRUGO, 129 &divas_fops);
130 proc_net_eicon);
131 if (!divas_proc_entry) 130 if (!divas_proc_entry)
132 return (0); 131 return (0);
133 132
134 divas_proc_entry->proc_fops = &divas_fops;
135 divas_proc_entry->owner = THIS_MODULE;
136
137 return (1); 133 return (1);
138} 134}
139 135
diff --git a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c
index 27d890b48f88..877be9922c3d 100644
--- a/drivers/isdn/hysdn/hysdn_procconf.c
+++ b/drivers/isdn/hysdn/hysdn_procconf.c
@@ -370,6 +370,7 @@ hysdn_conf_close(struct inode *ino, struct file *filep)
370/******************************************************/ 370/******************************************************/
371static const struct file_operations conf_fops = 371static const struct file_operations conf_fops =
372{ 372{
373 .owner = THIS_MODULE,
373 .llseek = no_llseek, 374 .llseek = no_llseek,
374 .read = hysdn_conf_read, 375 .read = hysdn_conf_read,
375 .write = hysdn_conf_write, 376 .write = hysdn_conf_write,
@@ -402,11 +403,9 @@ hysdn_procconf_init(void)
402 while (card) { 403 while (card) {
403 404
404 sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid); 405 sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid);
405 if ((card->procconf = (void *) create_proc_entry(conf_name, 406 if ((card->procconf = (void *) proc_create(conf_name,
406 S_IFREG | S_IRUGO | S_IWUSR, 407 S_IFREG | S_IRUGO | S_IWUSR,
407 hysdn_proc_entry)) != NULL) { 408 hysdn_proc_entry)) != NULL) {
408 ((struct proc_dir_entry *) card->procconf)->proc_fops = &conf_fops;
409 ((struct proc_dir_entry *) card->procconf)->owner = THIS_MODULE;
410 hysdn_proclog_init(card); /* init the log file entry */ 409 hysdn_proclog_init(card); /* init the log file entry */
411 } 410 }
412 card = card->next; /* next entry */ 411 card = card->next; /* next entry */
diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c
index 27b3991fb0ec..8991d2c8ee4a 100644
--- a/drivers/isdn/hysdn/hysdn_proclog.c
+++ b/drivers/isdn/hysdn/hysdn_proclog.c
@@ -380,6 +380,7 @@ hysdn_log_poll(struct file *file, poll_table * wait)
380/**************************************************/ 380/**************************************************/
381static const struct file_operations log_fops = 381static const struct file_operations log_fops =
382{ 382{
383 .owner = THIS_MODULE,
383 .llseek = no_llseek, 384 .llseek = no_llseek,
384 .read = hysdn_log_read, 385 .read = hysdn_log_read,
385 .write = hysdn_log_write, 386 .write = hysdn_log_write,
@@ -402,10 +403,9 @@ hysdn_proclog_init(hysdn_card * card)
402 403
403 if ((pd = kzalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) { 404 if ((pd = kzalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) {
404 sprintf(pd->log_name, "%s%d", PROC_LOG_BASENAME, card->myid); 405 sprintf(pd->log_name, "%s%d", PROC_LOG_BASENAME, card->myid);
405 if ((pd->log = create_proc_entry(pd->log_name, S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry)) != NULL) { 406 pd->log = proc_create(pd->log_name,
406 pd->log->proc_fops = &log_fops; 407 S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry,
407 pd->log->owner = THIS_MODULE; 408 &log_fops);
408 }
409 409
410 init_waitqueue_head(&(pd->rd_queue)); 410 init_waitqueue_head(&(pd->rd_queue));
411 411