aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/capi
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/isdn/capi
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/isdn/capi')
-rw-r--r--drivers/isdn/capi/kcapi_proc.c24
1 files changed, 10 insertions, 14 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