]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
isdn: use non-racy method for proc entries creation
authorDenis V. Lunev <den@openvz.org>
Tue, 29 Apr 2008 08:02:30 +0000 (01:02 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 29 Apr 2008 15:06:22 +0000 (08:06 -0700)
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>
drivers/isdn/capi/kcapi_proc.c
drivers/isdn/divert/divert_procfs.c
drivers/isdn/hardware/eicon/divasproc.c
drivers/isdn/hysdn/hysdn_procconf.c
drivers/isdn/hysdn/hysdn_proclog.c

index 845a797b00309e2fb45fb1ce3f9defd5ed943146..c29208bd752131e9d8406c193a48f2a5982df272 100644 (file)
@@ -114,6 +114,7 @@ static int seq_contrstats_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations proc_controller_ops = {
+       .owner          = THIS_MODULE,
        .open           = seq_controller_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
@@ -121,6 +122,7 @@ static const struct file_operations proc_controller_ops = {
 };
 
 static const struct file_operations proc_contrstats_ops = {
+       .owner          = THIS_MODULE,
        .open           = seq_contrstats_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
@@ -219,6 +221,7 @@ seq_applstats_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations proc_applications_ops = {
+       .owner          = THIS_MODULE,
        .open           = seq_applications_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
@@ -226,21 +229,13 @@ static const struct file_operations proc_applications_ops = {
 };
 
 static const struct file_operations proc_applstats_ops = {
+       .owner          = THIS_MODULE,
        .open           = seq_applstats_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
        .release        = seq_release,
 };
 
-static void
-create_seq_entry(char *name, mode_t mode, const struct file_operations *f)
-{
-       struct proc_dir_entry *entry;
-       entry = create_proc_entry(name, mode, NULL);
-       if (entry)
-               entry->proc_fops = f;
-}
-
 // ---------------------------------------------------------------------------
 
 static 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)
 }
 
 static const struct file_operations proc_driver_ops = {
+       .owner          = THIS_MODULE,
        .open           = seq_capi_driver_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
@@ -296,11 +292,11 @@ kcapi_proc_init(void)
 {
        proc_mkdir("capi",             NULL);
        proc_mkdir("capi/controllers", NULL);
-       create_seq_entry("capi/controller",   0, &proc_controller_ops);
-       create_seq_entry("capi/contrstats",   0, &proc_contrstats_ops);
-       create_seq_entry("capi/applications", 0, &proc_applications_ops);
-       create_seq_entry("capi/applstats",    0, &proc_applstats_ops);
-       create_seq_entry("capi/driver",       0, &proc_driver_ops);
+       proc_create("capi/controller",   0, NULL, &proc_controller_ops);
+       proc_create("capi/contrstats",   0, NULL, &proc_contrstats_ops);
+       proc_create("capi/applications", 0, NULL, &proc_applications_ops);
+       proc_create("capi/applstats",    0, NULL, &proc_applstats_ops);
+       proc_create("capi/driver",       0, NULL, &proc_driver_ops);
 }
 
 void __exit
index 4fd4c46892e3306ef3a18e181a4dc6e0735f4a9a..8b256a617c8a4524cec9f503ef7371ebbf30356b 100644 (file)
@@ -288,13 +288,12 @@ divert_dev_init(void)
        isdn_proc_entry = proc_mkdir("isdn", init_net.proc_net);
        if (!isdn_proc_entry)
                return (-1);
-       isdn_divert_entry = create_proc_entry("divert", S_IFREG | S_IRUGO, isdn_proc_entry);
+       isdn_divert_entry = proc_create("divert", S_IFREG | S_IRUGO,
+                                       isdn_proc_entry, &isdn_fops);
        if (!isdn_divert_entry) {
                remove_proc_entry("isdn", init_net.proc_net);
                return (-1);
        }
-       isdn_divert_entry->proc_fops = &isdn_fops; 
-       isdn_divert_entry->owner = THIS_MODULE; 
 #endif /* CONFIG_PROC_FS */
 
        return (0);
index 0632a260699858cf7bc7a3036d366b34d888eed5..fae895828a1713317a0286d21f17a4fe6b051a38 100644 (file)
@@ -125,15 +125,11 @@ static const struct file_operations divas_fops = {
 
 int create_divas_proc(void)
 {
-       divas_proc_entry = create_proc_entry(divas_proc_name,
-                                            S_IFREG | S_IRUGO,
-                                            proc_net_eicon);
+       proc_create(divas_proc_name, S_IFREG | S_IRUGO, proc_net_eicon,
+                   &divas_fops);
        if (!divas_proc_entry)
                return (0);
 
-       divas_proc_entry->proc_fops = &divas_fops;
-       divas_proc_entry->owner = THIS_MODULE;
-
        return (1);
 }
 
index 27d890b48f88a6d7d9fab0e78c6a596870391411..877be9922c3d24de4480d77dc25f017e86548092 100644 (file)
@@ -370,6 +370,7 @@ hysdn_conf_close(struct inode *ino, struct file *filep)
 /******************************************************/
 static const struct file_operations conf_fops =
 {
+       .owner          = THIS_MODULE,
        .llseek         = no_llseek,
        .read           = hysdn_conf_read,
        .write          = hysdn_conf_write,
@@ -402,11 +403,9 @@ hysdn_procconf_init(void)
        while (card) {
 
                sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid);
-               if ((card->procconf = (void *) create_proc_entry(conf_name,
-                                            S_IFREG | S_IRUGO | S_IWUSR,
-                                           hysdn_proc_entry)) != NULL) {
-                       ((struct proc_dir_entry *) card->procconf)->proc_fops = &conf_fops;
-                       ((struct proc_dir_entry *) card->procconf)->owner = THIS_MODULE;
+               if ((card->procconf = (void *) proc_create(conf_name,
+                                               S_IFREG | S_IRUGO | S_IWUSR,
+                                               hysdn_proc_entry)) != NULL) {
                        hysdn_proclog_init(card);       /* init the log file entry */
                }
                card = card->next;      /* next entry */
index 27b3991fb0ec600e031ae1f4627b173fea4a0ce9..8991d2c8ee4a9d74b02e15c9f44246c06593eb63 100644 (file)
@@ -380,6 +380,7 @@ hysdn_log_poll(struct file *file, poll_table * wait)
 /**************************************************/
 static const struct file_operations log_fops =
 {
+       .owner          = THIS_MODULE,
        .llseek         = no_llseek,
        .read           = hysdn_log_read,
        .write          = hysdn_log_write,
@@ -402,10 +403,9 @@ hysdn_proclog_init(hysdn_card * card)
 
        if ((pd = kzalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) {
                sprintf(pd->log_name, "%s%d", PROC_LOG_BASENAME, card->myid);
-               if ((pd->log = create_proc_entry(pd->log_name, S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry)) != NULL) {
-                       pd->log->proc_fops = &log_fops; 
-                       pd->log->owner = THIS_MODULE;
-               }
+               pd->log = proc_create(pd->log_name,
+                               S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry,
+                               &log_fops);
 
                init_waitqueue_head(&(pd->rd_queue));