* [PATCH 0/29] proc entries creation race
@ 2008-04-08 11:18 Denis V. Lunev
2008-04-08 11:19 ` [PATCH 1/29] proc: introduce proc_create_data to setup de->data Denis V. Lunev
` (28 more replies)
0 siblings, 29 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:18 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
This set of patches fixes an proc ->open'less usage due to ->proc_fops
flip in the most part of the kernel code. The original OOPS is described
in the commit 2d3a4e3666325a9709cc8ea2e88151394e8f20fc.
In addition to this, proc_create_data is introduced to fix reading from
proc without PDE->data. The race is basically the same as above.
create_proc_entries is replaced in the entire kernel code as new method
is also simply better.
Signed-off-by: Denis V. Lunev <den@openvz.org>
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH 1/29] proc: introduce proc_create_data to setup de->data
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 2/29] nfsd: use proc_create to setup de->proc_fops Denis V. Lunev
` (27 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
The problem is the same as for de->proc_fops. Right now PDE becomes visible
without data set. So, the entry could be looked up without data. This, in
most cases, will simply OOPS.
proc_create_data call is created to address this issue. proc_create now
becomes a wrapper around it.
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
fs/proc/generic.c | 8 +++++---
fs/proc/root.c | 2 +-
include/linux/proc_fs.h | 17 +++++++++++++++--
3 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 8b406e2..b9ec046 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -680,9 +680,10 @@ struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
return ent;
}
-struct proc_dir_entry *proc_create(const char *name, mode_t mode,
- struct proc_dir_entry *parent,
- const struct file_operations *proc_fops)
+struct proc_dir_entry *proc_create_data(const char *name, mode_t mode,
+ struct proc_dir_entry *parent,
+ const struct file_operations *proc_fops,
+ void *data)
{
struct proc_dir_entry *pde;
nlink_t nlink;
@@ -703,6 +704,7 @@ struct proc_dir_entry *proc_create(const char *name, mode_t mode,
if (!pde)
goto out;
pde->proc_fops = proc_fops;
+ pde->data = data;
if (proc_register(parent, pde) < 0)
goto out_free;
return pde;
diff --git a/fs/proc/root.c b/fs/proc/root.c
index c741b45..9511753 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -230,5 +230,5 @@ void pid_ns_release_proc(struct pid_namespace *ns)
EXPORT_SYMBOL(proc_symlink);
EXPORT_SYMBOL(proc_mkdir);
EXPORT_SYMBOL(create_proc_entry);
-EXPORT_SYMBOL(proc_create);
+EXPORT_SYMBOL(proc_create_data);
EXPORT_SYMBOL(remove_proc_entry);
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 2183ffd..c96a791 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -118,9 +118,10 @@ void de_put(struct proc_dir_entry *de);
extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
struct proc_dir_entry *parent);
-struct proc_dir_entry *proc_create(const char *name, mode_t mode,
+struct proc_dir_entry *proc_create_data(const char *name, mode_t mode,
struct proc_dir_entry *parent,
- const struct file_operations *proc_fops);
+ const struct file_operations *proc_fops,
+ void *data);
extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
extern struct vfsmount *proc_mnt;
@@ -175,6 +176,12 @@ extern struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *);
extern struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode,
struct proc_dir_entry *parent);
+static inline struct proc_dir_entry *proc_create(const char *name, mode_t mode,
+ struct proc_dir_entry *parent, const struct file_operations *proc_fops)
+{
+ return proc_create_data(name, mode, parent, proc_fops, NULL);
+}
+
static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
mode_t mode, struct proc_dir_entry *base,
read_proc_t *read_proc, void * data)
@@ -224,6 +231,12 @@ static inline struct proc_dir_entry *proc_create(const char *name,
{
return NULL;
}
+static inline struct proc_dir_entry *proc_create_data(const char *name,
+ mode_t mode, struct proc_dir_entry *parent,
+ const struct file_operations *proc_fops, void *data)
+{
+ return NULL;
+}
#define remove_proc_entry(name, parent) do {} while (0)
static inline struct proc_dir_entry *proc_symlink(const char *name,
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 2/29] nfsd: use proc_create to setup de->proc_fops
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
2008-04-08 11:19 ` [PATCH 1/29] proc: introduce proc_create_data to setup de->data Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 3/29] nfs: " Denis V. Lunev
` (26 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create() to make sure that ->proc_fops be setup before gluing
PDE to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Trond.Myklebust@netapp.com
---
fs/nfsd/nfsctl.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 613bcb8..b5163a3 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -160,6 +160,7 @@ static const struct file_operations exports_operations = {
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
+ .owner = THIS_MODULE,
};
/*----------------------------------------------------------------------------*/
@@ -736,10 +737,9 @@ static int create_proc_exports_entry(void)
entry = proc_mkdir("fs/nfs", NULL);
if (!entry)
return -ENOMEM;
- entry = create_proc_entry("fs/nfs/exports", 0, NULL);
+ entry = proc_create("exports", 0, entry, &exports_operations);
if (!entry)
return -ENOMEM;
- entry->proc_fops = &exports_operations;
return 0;
}
#else /* CONFIG_PROC_FS */
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 3/29] nfs: use proc_create to setup de->proc_fops
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
2008-04-08 11:19 ` [PATCH 1/29] proc: introduce proc_create_data to setup de->data Denis V. Lunev
2008-04-08 11:19 ` [PATCH 2/29] nfsd: use proc_create to setup de->proc_fops Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 4/29] afs: use non-racy method for proc entries creation Denis V. Lunev
` (25 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create() to make sure that ->proc_fops be setup before gluing
PDE to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Trond.Myklebust@netapp.com
---
fs/nfs/client.c | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 67a193f..6d62652 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1314,6 +1314,7 @@ static const struct file_operations nfs_server_list_fops = {
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
+ .owner = THIS_MODULE,
};
static int nfs_volume_list_open(struct inode *inode, struct file *file);
@@ -1334,6 +1335,7 @@ static const struct file_operations nfs_volume_list_fops = {
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
+ .owner = THIS_MODULE,
};
/*
@@ -1500,20 +1502,16 @@ int __init nfs_fs_proc_init(void)
proc_fs_nfs->owner = THIS_MODULE;
/* a file of servers with which we're dealing */
- p = create_proc_entry("servers", S_IFREG|S_IRUGO, proc_fs_nfs);
+ p = proc_create("servers", S_IFREG|S_IRUGO,
+ proc_fs_nfs, &nfs_server_list_fops);
if (!p)
goto error_1;
- p->proc_fops = &nfs_server_list_fops;
- p->owner = THIS_MODULE;
-
/* a file of volumes that we have mounted */
- p = create_proc_entry("volumes", S_IFREG|S_IRUGO, proc_fs_nfs);
+ p = proc_create("volumes", S_IFREG|S_IRUGO,
+ proc_fs_nfs, &nfs_volume_list_fops);
if (!p)
goto error_2;
-
- p->proc_fops = &nfs_volume_list_fops;
- p->owner = THIS_MODULE;
return 0;
error_2:
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 4/29] afs: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (2 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 3/29] nfs: " Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 5/29] ext4: " Denis V. Lunev
` (24 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create()/proc_create_data() to make sure that ->proc_fops and
->data be setup before gluing PDE to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: David Howells <dhowells@redhat.com>
---
fs/afs/proc.c | 33 ++++++++++++++-------------------
1 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/fs/afs/proc.c b/fs/afs/proc.c
index 846c761..9f7d1ae 100644
--- a/fs/afs/proc.c
+++ b/fs/afs/proc.c
@@ -41,6 +41,7 @@ static const struct file_operations afs_proc_cells_fops = {
.write = afs_proc_cells_write,
.llseek = seq_lseek,
.release = seq_release,
+ .owner = THIS_MODULE,
};
static int afs_proc_rootcell_open(struct inode *inode, struct file *file);
@@ -56,7 +57,8 @@ static const struct file_operations afs_proc_rootcell_fops = {
.read = afs_proc_rootcell_read,
.write = afs_proc_rootcell_write,
.llseek = no_llseek,
- .release = afs_proc_rootcell_release
+ .release = afs_proc_rootcell_release,
+ .owner = THIS_MODULE,
};
static int afs_proc_cell_volumes_open(struct inode *inode, struct file *file);
@@ -80,6 +82,7 @@ static const struct file_operations afs_proc_cell_volumes_fops = {
.read = seq_read,
.llseek = seq_lseek,
.release = afs_proc_cell_volumes_release,
+ .owner = THIS_MODULE,
};
static int afs_proc_cell_vlservers_open(struct inode *inode,
@@ -104,6 +107,7 @@ static const struct file_operations afs_proc_cell_vlservers_fops = {
.read = seq_read,
.llseek = seq_lseek,
.release = afs_proc_cell_vlservers_release,
+ .owner = THIS_MODULE,
};
static int afs_proc_cell_servers_open(struct inode *inode, struct file *file);
@@ -127,6 +131,7 @@ static const struct file_operations afs_proc_cell_servers_fops = {
.read = seq_read,
.llseek = seq_lseek,
.release = afs_proc_cell_servers_release,
+ .owner = THIS_MODULE,
};
/*
@@ -143,17 +148,13 @@ int afs_proc_init(void)
goto error_dir;
proc_afs->owner = THIS_MODULE;
- p = create_proc_entry("cells", 0, proc_afs);
+ p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
if (!p)
goto error_cells;
- p->proc_fops = &afs_proc_cells_fops;
- p->owner = THIS_MODULE;
- p = create_proc_entry("rootcell", 0, proc_afs);
+ p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
if (!p)
goto error_rootcell;
- p->proc_fops = &afs_proc_rootcell_fops;
- p->owner = THIS_MODULE;
_leave(" = 0");
return 0;
@@ -395,26 +396,20 @@ int afs_proc_cell_setup(struct afs_cell *cell)
if (!cell->proc_dir)
goto error_dir;
- p = create_proc_entry("servers", 0, cell->proc_dir);
+ p = proc_create_data("servers", 0, cell->proc_dir,
+ &afs_proc_cell_servers_fops, cell);
if (!p)
goto error_servers;
- p->proc_fops = &afs_proc_cell_servers_fops;
- p->owner = THIS_MODULE;
- p->data = cell;
- p = create_proc_entry("vlservers", 0, cell->proc_dir);
+ p = proc_create_data("vlservers", 0, cell->proc_dir,
+ &afs_proc_cell_vlservers_fops, cell);
if (!p)
goto error_vlservers;
- p->proc_fops = &afs_proc_cell_vlservers_fops;
- p->owner = THIS_MODULE;
- p->data = cell;
- p = create_proc_entry("volumes", 0, cell->proc_dir);
+ p = proc_create_data("volumes", 0, cell->proc_dir,
+ &afs_proc_cell_volumes_fops, cell);
if (!p)
goto error_volumes;
- p->proc_fops = &afs_proc_cell_volumes_fops;
- p->owner = THIS_MODULE;
- p->data = cell;
_leave(" = 0");
return 0;
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 5/29] ext4: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (3 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 4/29] afs: use non-racy method for proc entries creation Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 6/29] reiserfs: " Denis V. Lunev
` (23 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create()/proc_create_data() to make sure that ->proc_fops and
->data be setup before gluing PDE to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: sct@redhat.com
CC: adilger@clusterfs.com
CC: linux-ext4@vger.kernel.org
---
fs/ext4/mballoc.c | 15 ++++-----------
1 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 9a6c70f..cbb47a0 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2455,17 +2455,10 @@ static void ext4_mb_history_init(struct super_block *sb)
int i;
if (sbi->s_mb_proc != NULL) {
- struct proc_dir_entry *p;
- p = create_proc_entry("mb_history", S_IRUGO, sbi->s_mb_proc);
- if (p) {
- p->proc_fops = &ext4_mb_seq_history_fops;
- p->data = sb;
- }
- p = create_proc_entry("mb_groups", S_IRUGO, sbi->s_mb_proc);
- if (p) {
- p->proc_fops = &ext4_mb_seq_groups_fops;
- p->data = sb;
- }
+ proc_create_data("mb_history", S_IRUGO, sbi->s_mb_proc,
+ &ext4_mb_seq_history_fops, sb);
+ proc_create_data("mb_groups", S_IRUGO, sbi->s_mb_proc,
+ &ext4_mb_seq_groups_fops, sb);
}
sbi->s_mb_history_max = 1000;
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 6/29] reiserfs: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (4 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 5/29] ext4: " Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 7/29] jbd2: " Denis V. Lunev
` (22 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create()/proc_create_data() to make sure that ->proc_fops and
->data be setup before gluing PDE to main tree.
/proc entry owner is also added.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: reiserfs-dev@namesys.com
CC: reiserfs-devel@vger.kernel.org
---
fs/reiserfs/procfs.c | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
index 8f86c52..b9dbeec 100644
--- a/fs/reiserfs/procfs.c
+++ b/fs/reiserfs/procfs.c
@@ -467,6 +467,7 @@ static const struct file_operations r_file_operations = {
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
+ .owner = THIS_MODULE,
};
static struct proc_dir_entry *proc_info_root = NULL;
@@ -475,12 +476,8 @@ static const char proc_info_root_name[] = "fs/reiserfs";
static void add_file(struct super_block *sb, char *name,
int (*func) (struct seq_file *, struct super_block *))
{
- struct proc_dir_entry *de;
- de = create_proc_entry(name, 0, REISERFS_SB(sb)->procdir);
- if (de) {
- de->data = func;
- de->proc_fops = &r_file_operations;
- }
+ proc_create_data(name, 0, REISERFS_SB(sb)->procdir,
+ &r_file_operations, func);
}
int reiserfs_proc_info_init(struct super_block *sb)
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 7/29] jbd2: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (5 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 6/29] reiserfs: " Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 8/29] proc: use non-racy method for /proc/page_owner creation Denis V. Lunev
` (21 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create()/proc_create_data() to make sure that ->proc_fops and
->data be setup before gluing PDE to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: sct@redhat.com
CC: adilger@clusterfs.com
CC: linux-ext4@vger.kernel.org
---
fs/jbd2/journal.c | 17 ++++-------------
1 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 6ea7801..255e0dc 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -904,19 +904,10 @@ static void jbd2_stats_proc_init(journal_t *journal)
snprintf(name, sizeof(name) - 1, "%s", bdevname(journal->j_dev, name));
journal->j_proc_entry = proc_mkdir(name, proc_jbd2_stats);
if (journal->j_proc_entry) {
- struct proc_dir_entry *p;
- p = create_proc_entry("history", S_IRUGO,
- journal->j_proc_entry);
- if (p) {
- p->proc_fops = &jbd2_seq_history_fops;
- p->data = journal;
- p = create_proc_entry("info", S_IRUGO,
- journal->j_proc_entry);
- if (p) {
- p->proc_fops = &jbd2_seq_info_fops;
- p->data = journal;
- }
- }
+ proc_create_data("history", S_IRUGO, journal->j_proc_entry,
+ &jbd2_seq_history_fops, journal);
+ proc_create_data("info", S_IRUGO, journal->j_proc_entry,
+ &jbd2_seq_info_fops, journal);
}
}
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 8/29] proc: use non-racy method for /proc/page_owner creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (6 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 7/29] jbd2: " Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 9/29] sysvipc: use non-racy method for proc entries creation Denis V. Lunev
` (20 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create()/proc_create_data() to make sure that ->proc_fops and
->data be setup before gluing PDE to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
fs/proc/proc_misc.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 0390844..fbaf067 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -1041,12 +1041,10 @@ void __init proc_misc_init(void)
#ifdef CONFIG_PAGE_OWNER
{
struct proc_dir_entry *entry;
- entry = create_proc_entry("page_owner",
- S_IWUSR | S_IRUGO, NULL);
- if (entry) {
- entry->proc_fops = &proc_page_owner_operations;
+ entry = proc_create("page_owner",
+ S_IWUSR | S_IRUGO, NULL, &proc_page_owner_operations);
+ if (entry)
entry->size = 1024;
- }
}
#endif
}
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 9/29] sysvipc: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (7 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 8/29] proc: use non-racy method for /proc/page_owner creation Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 10/29] mm: use non-racy method for /proc/swaps creation Denis V. Lunev
` (19 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create_data() to make sure that ->proc_fops and ->data be setup
before gluing PDE to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
ipc/util.c | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/ipc/util.c b/ipc/util.c
index 4c465cb..3339177 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -165,13 +165,12 @@ void __init ipc_init_proc_interface(const char *path, const char *header,
iface->ids = ids;
iface->show = show;
- pde = create_proc_entry(path,
- S_IRUGO, /* world readable */
- NULL /* parent dir */);
- if (pde) {
- pde->data = iface;
- pde->proc_fops = &sysvipc_proc_fops;
- } else {
+ pde = proc_create_data(path,
+ S_IRUGO, /* world readable */
+ NULL, /* parent dir */
+ &sysvipc_proc_fops,
+ iface);
+ if (!pde) {
kfree(iface);
}
}
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 10/29] mm: use non-racy method for /proc/swaps creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (8 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 9/29] sysvipc: use non-racy method for proc entries creation Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 11/29] sound: use non-racy method for /proc/driver/snd-page-alloc creation Denis V. Lunev
` (18 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create() to make sure that ->proc_fops be setup before gluing
PDE to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
mm/swapfile.c | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 67051be..bd1bb59 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1426,11 +1426,7 @@ static const struct file_operations proc_swaps_operations = {
static int __init procswaps_init(void)
{
- struct proc_dir_entry *entry;
-
- entry = create_proc_entry("swaps", 0, NULL);
- if (entry)
- entry->proc_fops = &proc_swaps_operations;
+ proc_create("swaps", 0, NULL, &proc_swaps_operations);
return 0;
}
__initcall(procswaps_init);
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 11/29] sound: use non-racy method for /proc/driver/snd-page-alloc creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (9 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 10/29] mm: use non-racy method for /proc/swaps creation Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 12/29] zorro: use non-racy method for proc entries creation Denis V. Lunev
` (17 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create() to make sure that ->proc_fops be setup before gluing
PDE to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
sound/core/memalloc.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c
index 920e578..23b7bc0 100644
--- a/sound/core/memalloc.c
+++ b/sound/core/memalloc.c
@@ -629,9 +629,8 @@ static const struct file_operations snd_mem_proc_fops = {
static int __init snd_mem_init(void)
{
#ifdef CONFIG_PROC_FS
- snd_mem_proc = create_proc_entry(SND_MEM_PROC_FILE, 0644, NULL);
- if (snd_mem_proc)
- snd_mem_proc->proc_fops = &snd_mem_proc_fops;
+ snd_mem_proc = proc_create(SND_MEM_PROC_FILE, 0644, NULL,
+ &snd_mem_proc_fops);
#endif
return 0;
}
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 12/29] zorro: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (10 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 11/29] sound: use non-racy method for /proc/driver/snd-page-alloc creation Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 13/29] samples: use non-racy method for /proc/marker-example creation Denis V. Lunev
` (16 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
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: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/zorro/proc.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/zorro/proc.c b/drivers/zorro/proc.c
index b7a8c7b..2de70fc 100644
--- a/drivers/zorro/proc.c
+++ b/drivers/zorro/proc.c
@@ -76,6 +76,7 @@ proc_bus_zorro_read(struct file *file, char __user *buf, size_t nbytes, loff_t *
}
static const struct file_operations proc_bus_zorro_operations = {
+ .owner = THIS_MODULE,
.llseek = proc_bus_zorro_lseek,
.read = proc_bus_zorro_read,
};
@@ -114,11 +115,11 @@ static int __init zorro_proc_attach_device(u_int slot)
char name[4];
sprintf(name, "%02x", slot);
- entry = create_proc_entry(name, 0, proc_bus_zorro_dir);
+ entry = proc_create_data(name, 0, proc_bus_zorro_dir,
+ &proc_bus_zorro_operations,
+ &zorro_autocon[slot]);
if (!entry)
return -ENOMEM;
- entry->proc_fops = &proc_bus_zorro_operations;
- entry->data = &zorro_autocon[slot];
entry->size = sizeof(struct zorro_dev);
return 0;
}
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 13/29] samples: use non-racy method for /proc/marker-example creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (11 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 12/29] zorro: use non-racy method for proc entries creation Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 14/29] scsi: use non-racy method for proc entries creation Denis V. Lunev
` (15 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create() to make sure that ->proc_fops be setup before gluing PDE
to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
---
samples/markers/marker-example.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/samples/markers/marker-example.c b/samples/markers/marker-example.c
index 05e438f..e90dc5d 100644
--- a/samples/markers/marker-example.c
+++ b/samples/markers/marker-example.c
@@ -33,10 +33,8 @@ static struct file_operations mark_ops = {
static int example_init(void)
{
printk(KERN_ALERT "example init\n");
- pentry_example = create_proc_entry("marker-example", 0444, NULL);
- if (pentry_example)
- pentry_example->proc_fops = &mark_ops;
- else
+ pentry_example = proc_create("marker-example", 0444, NULL, &mark_ops);
+ if (!pentry_example)
return -EPERM;
return 0;
}
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 14/29] scsi: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (12 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 13/29] samples: use non-racy method for /proc/marker-example creation Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 15/29] usb: " Denis V. Lunev
` (14 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create() to make sure that ->proc_fops 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: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/scsi/scsi_proc.c | 4 ++--
drivers/scsi/sg.c | 12 ++++--------
2 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
index db8163b..7b5563c 100644
--- a/drivers/scsi/scsi_proc.c
+++ b/drivers/scsi/scsi_proc.c
@@ -408,6 +408,7 @@ static int proc_scsi_open(struct inode *inode, struct file *file)
}
static const struct file_operations proc_scsi_operations = {
+ .owner = THIS_MODULE,
.open = proc_scsi_open,
.read = seq_read,
.write = proc_scsi_write,
@@ -426,10 +427,9 @@ int __init scsi_init_procfs(void)
if (!proc_scsi)
goto err1;
- pde = create_proc_entry("scsi/scsi", 0, NULL);
+ pde = proc_create("scsi/scsi", 0, NULL, &proc_scsi_operations);
if (!pde)
goto err2;
- pde->proc_fops = &proc_scsi_operations;
return 0;
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 2029422..c9d7f72 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -2667,7 +2667,6 @@ sg_proc_init(void)
{
int k, mask;
int num_leaves = ARRAY_SIZE(sg_proc_leaf_arr);
- struct proc_dir_entry *pdep;
struct sg_proc_leaf * leaf;
sg_proc_sgp = proc_mkdir(sg_proc_sg_dirname, NULL);
@@ -2676,13 +2675,10 @@ sg_proc_init(void)
for (k = 0; k < num_leaves; ++k) {
leaf = &sg_proc_leaf_arr[k];
mask = leaf->fops->write ? S_IRUGO | S_IWUSR : S_IRUGO;
- pdep = create_proc_entry(leaf->name, mask, sg_proc_sgp);
- if (pdep) {
- leaf->fops->owner = THIS_MODULE,
- leaf->fops->read = seq_read,
- leaf->fops->llseek = seq_lseek,
- pdep->proc_fops = leaf->fops;
- }
+ leaf->fops->owner = THIS_MODULE;
+ leaf->fops->read = seq_read;
+ leaf->fops->llseek = seq_lseek;
+ proc_create(leaf->name, mask, sg_proc_sgp, leaf->fops);
}
return 0;
}
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 15/29] usb: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (13 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 14/29] scsi: use non-racy method for proc entries creation Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 16/29] s390: " Denis V. Lunev
` (13 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create()/proc_create_data() to make sure that ->proc_fops and
->data be setup before gluing PDE to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/usb/gadget/at91_udc.c | 11 ++---------
drivers/usb/gadget/omap_udc.c | 7 ++-----
drivers/usb/host/sl811-hcd.c | 10 +---------
3 files changed, 5 insertions(+), 23 deletions(-)
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 6ba0ca5..3fdff1e 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -231,6 +231,7 @@ static int proc_udc_open(struct inode *inode, struct file *file)
}
static const struct file_operations proc_ops = {
+ .owner = THIS_MODULE,
.open = proc_udc_open,
.read = seq_read,
.llseek = seq_lseek,
@@ -239,15 +240,7 @@ static const struct file_operations proc_ops = {
static void create_debug_file(struct at91_udc *udc)
{
- struct proc_dir_entry *pde;
-
- pde = create_proc_entry (debug_filename, 0, NULL);
- udc->pde = pde;
- if (pde == NULL)
- return;
-
- pde->proc_fops = &proc_ops;
- pde->data = udc;
+ udc->pde = proc_create_data(debug_filename, 0, NULL, &proc_ops, udc);
}
static void remove_debug_file(struct at91_udc *udc)
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 49de9d7..ab0d5eb 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -2504,6 +2504,7 @@ static int proc_udc_open(struct inode *inode, struct file *file)
}
static const struct file_operations proc_ops = {
+ .owner = THIS_MODULE,
.open = proc_udc_open,
.read = seq_read,
.llseek = seq_lseek,
@@ -2512,11 +2513,7 @@ static const struct file_operations proc_ops = {
static void create_proc_file(void)
{
- struct proc_dir_entry *pde;
-
- pde = create_proc_entry (proc_filename, 0, NULL);
- if (pde)
- pde->proc_fops = &proc_ops;
+ proc_create(proc_filename, 0, NULL, &proc_ops);
}
static void remove_proc_file(void)
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index ec349d4..7397d37 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -1505,15 +1505,7 @@ static const char proc_filename[] = "driver/sl811h";
static void create_debug_file(struct sl811 *sl811)
{
- struct proc_dir_entry *pde;
-
- pde = create_proc_entry(proc_filename, 0, NULL);
- if (pde == NULL)
- return;
-
- pde->proc_fops = &proc_ops;
- pde->data = sl811;
- sl811->pde = pde;
+ sl811->pde = proc_create_data(proc_filename, 0, NULL, &proc_ops, sl811);
}
static void remove_debug_file(struct sl811 *sl811)
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 16/29] s390: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (14 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 15/29] usb: " Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 17/29] arm: use non-racy method for /proc/davinci_clocks creation Denis V. Lunev
` (12 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create() to make sure that ->proc_fops be setup before gluing PDE
to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: linux-s390@vger.kernel.org
CC: Martin Schwidefsky <schwidefsky@de.ibm.com>
CC: Heiko Carstens <heiko.carstens@de.ibm.com>
---
drivers/s390/block/dasd_proc.c | 10 +++++-----
drivers/s390/char/tape_proc.c | 7 +++----
drivers/s390/cio/blacklist.c | 7 ++-----
3 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/drivers/s390/block/dasd_proc.c b/drivers/s390/block/dasd_proc.c
index 8ae9406..03c0e40 100644
--- a/drivers/s390/block/dasd_proc.c
+++ b/drivers/s390/block/dasd_proc.c
@@ -157,6 +157,7 @@ static int dasd_devices_open(struct inode *inode, struct file *file)
}
static const struct file_operations dasd_devices_file_ops = {
+ .owner = THIS_MODULE,
.open = dasd_devices_open,
.read = seq_read,
.llseek = seq_lseek,
@@ -315,13 +316,12 @@ dasd_proc_init(void)
if (!dasd_proc_root_entry)
goto out_nodasd;
dasd_proc_root_entry->owner = THIS_MODULE;
- dasd_devices_entry = create_proc_entry("devices",
- S_IFREG | S_IRUGO | S_IWUSR,
- dasd_proc_root_entry);
+ dasd_devices_entry = proc_create("devices",
+ S_IFREG | S_IRUGO | S_IWUSR,
+ dasd_proc_root_entry,
+ &dasd_devices_file_ops);
if (!dasd_devices_entry)
goto out_nodevices;
- dasd_devices_entry->proc_fops = &dasd_devices_file_ops;
- dasd_devices_entry->owner = THIS_MODULE;
dasd_statistics_entry = create_proc_entry("statistics",
S_IFREG | S_IRUGO | S_IWUSR,
dasd_proc_root_entry);
diff --git a/drivers/s390/char/tape_proc.c b/drivers/s390/char/tape_proc.c
index 0c39636..e7c888c 100644
--- a/drivers/s390/char/tape_proc.c
+++ b/drivers/s390/char/tape_proc.c
@@ -111,6 +111,7 @@ static int tape_proc_open(struct inode *inode, struct file *file)
static const struct file_operations tape_proc_ops =
{
+ .owner = THIS_MODULE,
.open = tape_proc_open,
.read = seq_read,
.llseek = seq_lseek,
@@ -124,14 +125,12 @@ void
tape_proc_init(void)
{
tape_proc_devices =
- create_proc_entry ("tapedevices", S_IFREG | S_IRUGO | S_IWUSR,
- NULL);
+ proc_create("tapedevices", S_IFREG | S_IRUGO | S_IWUSR, NULL,
+ &tape_proc_ops);
if (tape_proc_devices == NULL) {
PRINT_WARN("tape: Cannot register procfs entry tapedevices\n");
return;
}
- tape_proc_devices->proc_fops = &tape_proc_ops;
- tape_proc_devices->owner = THIS_MODULE;
}
/*
diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c
index ef33d5d..40ef948 100644
--- a/drivers/s390/cio/blacklist.c
+++ b/drivers/s390/cio/blacklist.c
@@ -374,13 +374,10 @@ cio_ignore_proc_init (void)
{
struct proc_dir_entry *entry;
- entry = create_proc_entry ("cio_ignore", S_IFREG | S_IRUGO | S_IWUSR,
- NULL);
+ entry = proc_create("cio_ignore", S_IFREG | S_IRUGO | S_IWUSR, NULL,
+ &cio_ignore_proc_fops);
if (!entry)
return -ENOENT;
-
- entry->proc_fops = &cio_ignore_proc_fops;
-
return 0;
}
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 17/29] arm: use non-racy method for /proc/davinci_clocks creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (15 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 16/29] s390: " Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 18/29] avr32: proc: use non-racy method for /proc/tlb creation Denis V. Lunev
` (11 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create() to make sure that ->proc_fops be setup before gluing PDE
to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Russell King <rmk@arm.linux.org.uk>
---
arch/arm/mach-davinci/clock.c | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index 4143828..c6b94f6 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -311,11 +311,7 @@ static const struct file_operations proc_davinci_ck_operations = {
static int __init davinci_ck_proc_init(void)
{
- struct proc_dir_entry *entry;
-
- entry = create_proc_entry("davinci_clocks", 0, NULL);
- if (entry)
- entry->proc_fops = &proc_davinci_ck_operations;
+ proc_create("davinci_clocks", 0, NULL, &proc_davinci_ck_operations);
return 0;
}
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 18/29] avr32: proc: use non-racy method for /proc/tlb creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (16 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 17/29] arm: use non-racy method for /proc/davinci_clocks creation Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 19/29] cris: use non-racy method for /proc/system_profile creation Denis V. Lunev
` (10 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create() to make sure that ->proc_fops be setup before gluing PDE
to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Haavard Skinnemoen <hskinnemoen@atmel.com>
---
arch/avr32/mm/tlb.c | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/arch/avr32/mm/tlb.c b/arch/avr32/mm/tlb.c
index b835257..cd12edb 100644
--- a/arch/avr32/mm/tlb.c
+++ b/arch/avr32/mm/tlb.c
@@ -369,11 +369,7 @@ static const struct file_operations proc_tlb_operations = {
static int __init proctlb_init(void)
{
- struct proc_dir_entry *entry;
-
- entry = create_proc_entry("tlb", 0, NULL);
- if (entry)
- entry->proc_fops = &proc_tlb_operations;
+ proc_create("tlb", 0, NULL, &proc_tlb_operations);
return 0;
}
late_initcall(proctlb_init);
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 19/29] cris: use non-racy method for /proc/system_profile creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (17 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 18/29] avr32: proc: use non-racy method for /proc/tlb creation Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 20/29] ia64: use non-racy method for proc entries creation Denis V. Lunev
` (9 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create() to make sure that ->proc_fops be setup before gluing PDE
to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Mikael Starvik <starvik@axis.com>
CC: Jesper Nilsson <jesper.nilsson@axis.com>
---
arch/cris/kernel/profile.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/cris/kernel/profile.c b/arch/cris/kernel/profile.c
index aad0a9e..44f7b4f 100644
--- a/arch/cris/kernel/profile.c
+++ b/arch/cris/kernel/profile.c
@@ -75,9 +75,9 @@ __init init_cris_profile(void)
sample_buffer_pos = sample_buffer;
- entry = create_proc_entry("system_profile", S_IWUSR | S_IRUGO, NULL);
+ entry = proc_create("system_profile", S_IWUSR | S_IRUGO, NULL,
+ &cris_proc_profile_operations);
if (entry) {
- entry->proc_fops = &cris_proc_profile_operations;
entry->size = SAMPLE_BUFFER_SIZE;
}
prof_running = 1;
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 20/29] ia64: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (18 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 19/29] cris: use non-racy method for /proc/system_profile creation Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 21/29] parisc: use non-racy method for /proc/pcxl_dma creation Denis V. Lunev
` (8 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create()/proc_create_data() to make sure that ->proc_fops and
->data be setup before gluing PDE to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Tony Luck <tony.luck@intel.com>
CC: linux-ia64@vger.kernel.org
---
arch/ia64/hp/common/sba_iommu.c | 6 ++----
arch/ia64/kernel/perfmon.c | 6 +-----
arch/ia64/kernel/salinfo.c | 10 ++++------
arch/ia64/sn/kernel/sn2/sn2_smp.c | 5 +++--
arch/ia64/sn/kernel/sn2/sn_proc_fs.c | 29 ++++++++++-------------------
5 files changed, 20 insertions(+), 36 deletions(-)
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index 6ce729f..34421ae 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -1932,15 +1932,13 @@ static const struct file_operations ioc_fops = {
static void __init
ioc_proc_init(void)
{
- struct proc_dir_entry *dir, *entry;
+ struct proc_dir_entry *dir;
dir = proc_mkdir("bus/mckinley", NULL);
if (!dir)
return;
- entry = create_proc_entry(ioc_list->name, 0, dir);
- if (entry)
- entry->proc_fops = &ioc_fops;
+ proc_create(ioc_list->name, 0, dir, &ioc_fops);
}
#endif
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index a2aabfd..c66c588 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -6695,16 +6695,12 @@ pfm_init(void)
/*
* create /proc/perfmon (mostly for debugging purposes)
*/
- perfmon_dir = create_proc_entry("perfmon", S_IRUGO, NULL);
+ perfmon_dir = proc_create("perfmon", S_IRUGO, NULL, &pfm_proc_fops);
if (perfmon_dir == NULL) {
printk(KERN_ERR "perfmon: cannot create /proc entry, perfmon disabled\n");
pmu_conf = NULL;
return -1;
}
- /*
- * install customized file operations for /proc/perfmon entry
- */
- perfmon_dir->proc_fops = &pfm_proc_fops;
/*
* create /proc/sys/kernel/perfmon (for debugging purposes)
diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
index 779c3cc..012551f 100644
--- a/arch/ia64/kernel/salinfo.c
+++ b/arch/ia64/kernel/salinfo.c
@@ -648,18 +648,16 @@ salinfo_init(void)
if (!dir)
continue;
- entry = create_proc_entry("event", S_IRUSR, dir);
+ entry = proc_create_data("event", S_IRUSR, dir,
+ &salinfo_event_fops, data);
if (!entry)
continue;
- entry->data = data;
- entry->proc_fops = &salinfo_event_fops;
*sdir++ = entry;
- entry = create_proc_entry("data", S_IRUSR | S_IWUSR, dir);
+ entry = proc_create_data("data", S_IRUSR | S_IWUSR, dir,
+ &salinfo_data_fops, data);
if (!entry)
continue;
- entry->data = data;
- entry->proc_fops = &salinfo_data_fops;
*sdir++ = entry;
/* we missed any events before now */
diff --git a/arch/ia64/sn/kernel/sn2/sn2_smp.c b/arch/ia64/sn/kernel/sn2/sn2_smp.c
index dfc6bf1..49d3120 100644
--- a/arch/ia64/sn/kernel/sn2/sn2_smp.c
+++ b/arch/ia64/sn/kernel/sn2/sn2_smp.c
@@ -550,11 +550,12 @@ static int __init sn2_ptc_init(void)
if (!ia64_platform_is("sn2"))
return 0;
- if (!(proc_sn2_ptc = create_proc_entry(PTC_BASENAME, 0444, NULL))) {
+ proc_sn2_ptc = proc_create(PTC_BASENAME, 0444,
+ NULL, &proc_sn2_ptc_operations);
+ if (!&proc_sn2_ptc_operations) {
printk(KERN_ERR "unable to create %s proc entry", PTC_BASENAME);
return -EINVAL;
}
- proc_sn2_ptc->proc_fops = &proc_sn2_ptc_operations;
spin_lock_init(&sn2_global_ptc_lock);
return 0;
}
diff --git a/arch/ia64/sn/kernel/sn2/sn_proc_fs.c b/arch/ia64/sn/kernel/sn2/sn_proc_fs.c
index 62b3e9a..2526e5c 100644
--- a/arch/ia64/sn/kernel/sn2/sn_proc_fs.c
+++ b/arch/ia64/sn/kernel/sn2/sn_proc_fs.c
@@ -139,30 +139,21 @@ static const struct file_operations proc_sn_topo_fops = {
void register_sn_procfs(void)
{
static struct proc_dir_entry *sgi_proc_dir = NULL;
- struct proc_dir_entry *pde;
BUG_ON(sgi_proc_dir != NULL);
if (!(sgi_proc_dir = proc_mkdir("sgi_sn", NULL)))
return;
- pde = create_proc_entry("partition_id", 0444, sgi_proc_dir);
- if (pde)
- pde->proc_fops = &proc_partition_id_fops;
- pde = create_proc_entry("system_serial_number", 0444, sgi_proc_dir);
- if (pde)
- pde->proc_fops = &proc_system_sn_fops;
- pde = create_proc_entry("licenseID", 0444, sgi_proc_dir);
- if (pde)
- pde->proc_fops = &proc_license_id_fops;
- pde = create_proc_entry("sn_force_interrupt", 0644, sgi_proc_dir);
- if (pde)
- pde->proc_fops = &proc_sn_force_intr_fops;
- pde = create_proc_entry("coherence_id", 0444, sgi_proc_dir);
- if (pde)
- pde->proc_fops = &proc_coherence_id_fops;
- pde = create_proc_entry("sn_topology", 0444, sgi_proc_dir);
- if (pde)
- pde->proc_fops = &proc_sn_topo_fops;
+ proc_create("partition_id", 0444, sgi_proc_dir,
+ &proc_partition_id_fops);
+ proc_create("system_serial_number", 0444, sgi_proc_dir,
+ &proc_system_sn_fops);
+ proc_create("licenseID", 0444, sgi_proc_dir, &proc_license_id_fops);
+ proc_create("sn_force_interrupt", 0644, sgi_proc_dir,
+ &proc_sn_force_intr_fops);
+ proc_create("coherence_id", 0444, sgi_proc_dir,
+ &proc_coherence_id_fops);
+ proc_create("sn_topology", 0444, sgi_proc_dir, &proc_sn_topo_fops);
}
#endif /* CONFIG_PROC_FS */
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 21/29] parisc: use non-racy method for /proc/pcxl_dma creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (19 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 20/29] ia64: use non-racy method for proc entries creation Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 22/29] powerpc: use non-racy method for proc entries creation Denis V. Lunev
` (7 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create() to make sure that ->proc_fops be setup before gluing PDE
to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Kyle McMartin <kyle@parisc-linux.org>
CC: Matthew Wilcox <matthew@wil.cx>
CC: Grant Grundler <grundler@parisc-linux.org>
CC: linux-parisc@vger.kernel.org
---
arch/parisc/kernel/pci-dma.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/arch/parisc/kernel/pci-dma.c b/arch/parisc/kernel/pci-dma.c
index 9448d4e..ccd61b9 100644
--- a/arch/parisc/kernel/pci-dma.c
+++ b/arch/parisc/kernel/pci-dma.c
@@ -397,10 +397,9 @@ pcxl_dma_init(void)
"pcxl_dma_init: Unable to create gsc /proc dir entry\n");
else {
struct proc_dir_entry* ent;
- ent = create_proc_entry("pcxl_dma", 0, proc_gsc_root);
- if (ent)
- ent->proc_fops = &proc_pcxl_dma_ops;
- else
+ ent = proc_create("pcxl_dma", 0, proc_gsc_root,
+ &proc_pcxl_dma_ops);
+ if (!ent)
printk(KERN_WARNING
"pci-dma.c: Unable to create pcxl_dma /proc entry.\n");
}
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 22/29] powerpc: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (20 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 21/29] parisc: use non-racy method for /proc/pcxl_dma creation Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 23/29] acpi: " Denis V. Lunev
` (6 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
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: Paul Mackerras <paulus@samba.org>
CC: linuxppc-dev@ozlabs.org
---
arch/powerpc/kernel/lparcfg.c | 6 +--
arch/powerpc/kernel/proc_ppc64.c | 5 +--
arch/powerpc/kernel/rtas-proc.c | 45 ++++++++------------------
arch/powerpc/kernel/rtas_flash.c | 13 ++-----
arch/powerpc/platforms/cell/spufs/sched.c | 3 +-
arch/powerpc/platforms/cell/spufs/sputrace.c | 3 +-
arch/powerpc/platforms/iseries/lpevents.c | 8 +---
arch/powerpc/platforms/iseries/mf.c | 6 ++--
arch/powerpc/platforms/iseries/proc.c | 8 +---
arch/powerpc/platforms/iseries/viopath.c | 7 +---
arch/powerpc/platforms/pseries/eeh.c | 10 +----
arch/powerpc/platforms/pseries/reconfig.c | 7 +---
arch/powerpc/platforms/pseries/rtasd.c | 7 ++--
13 files changed, 39 insertions(+), 89 deletions(-)
diff --git a/arch/powerpc/kernel/lparcfg.c b/arch/powerpc/kernel/lparcfg.c
index 1ffacc6..1e656b4 100644
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -591,10 +591,8 @@ int __init lparcfg_init(void)
!firmware_has_feature(FW_FEATURE_ISERIES))
mode |= S_IWUSR;
- ent = create_proc_entry("ppc64/lparcfg", mode, NULL);
- if (ent) {
- ent->proc_fops = &lparcfg_fops;
- } else {
+ ent = proc_create("ppc64/lparcfg", mode, NULL, &lparcfg_fops);
+ if (!ent) {
printk(KERN_ERR "Failed to create ppc64/lparcfg\n");
return -EIO;
}
diff --git a/arch/powerpc/kernel/proc_ppc64.c b/arch/powerpc/kernel/proc_ppc64.c
index f78dfce..c647dde 100644
--- a/arch/powerpc/kernel/proc_ppc64.c
+++ b/arch/powerpc/kernel/proc_ppc64.c
@@ -68,12 +68,11 @@ static int __init proc_ppc64_init(void)
{
struct proc_dir_entry *pde;
- pde = create_proc_entry("ppc64/systemcfg", S_IFREG|S_IRUGO, NULL);
+ pde = proc_create_data("ppc64/systemcfg", S_IFREG|S_IRUGO, NULL,
+ &page_map_fops, vdso_data);
if (!pde)
return 1;
- pde->data = vdso_data;
pde->size = PAGE_SIZE;
- pde->proc_fops = &page_map_fops;
return 0;
}
diff --git a/arch/powerpc/kernel/rtas-proc.c b/arch/powerpc/kernel/rtas-proc.c
index f2e3bc7..f9c6abc 100644
--- a/arch/powerpc/kernel/rtas-proc.c
+++ b/arch/powerpc/kernel/rtas-proc.c
@@ -255,8 +255,6 @@ static void check_location(struct seq_file *m, const char *c);
static int __init proc_rtas_init(void)
{
- struct proc_dir_entry *entry;
-
if (!machine_is(pseries))
return -ENODEV;
@@ -264,35 +262,20 @@ static int __init proc_rtas_init(void)
if (rtas_node == NULL)
return -ENODEV;
- entry = create_proc_entry("ppc64/rtas/progress", S_IRUGO|S_IWUSR, NULL);
- if (entry)
- entry->proc_fops = &ppc_rtas_progress_operations;
-
- entry = create_proc_entry("ppc64/rtas/clock", S_IRUGO|S_IWUSR, NULL);
- if (entry)
- entry->proc_fops = &ppc_rtas_clock_operations;
-
- entry = create_proc_entry("ppc64/rtas/poweron", S_IWUSR|S_IRUGO, NULL);
- if (entry)
- entry->proc_fops = &ppc_rtas_poweron_operations;
-
- entry = create_proc_entry("ppc64/rtas/sensors", S_IRUGO, NULL);
- if (entry)
- entry->proc_fops = &ppc_rtas_sensors_operations;
-
- entry = create_proc_entry("ppc64/rtas/frequency", S_IWUSR|S_IRUGO,
- NULL);
- if (entry)
- entry->proc_fops = &ppc_rtas_tone_freq_operations;
-
- entry = create_proc_entry("ppc64/rtas/volume", S_IWUSR|S_IRUGO, NULL);
- if (entry)
- entry->proc_fops = &ppc_rtas_tone_volume_operations;
-
- entry = create_proc_entry("ppc64/rtas/rmo_buffer", S_IRUSR, NULL);
- if (entry)
- entry->proc_fops = &ppc_rtas_rmo_buf_ops;
-
+ proc_create("ppc64/rtas/progress", S_IRUGO|S_IWUSR, NULL,
+ &ppc_rtas_progress_operations);
+ proc_create("ppc64/rtas/clock", S_IRUGO|S_IWUSR, NULL,
+ &ppc_rtas_clock_operations);
+ proc_create("ppc64/rtas/poweron", S_IWUSR|S_IRUGO, NULL,
+ &ppc_rtas_poweron_operations);
+ proc_create("ppc64/rtas/sensors", S_IRUGO, NULL,
+ &ppc_rtas_sensors_operations);
+ proc_create("ppc64/rtas/frequency", S_IWUSR|S_IRUGO, NULL,
+ &ppc_rtas_tone_freq_operations);
+ proc_create("ppc64/rtas/volume", S_IWUSR|S_IRUGO, NULL,
+ &ppc_rtas_tone_volume_operations);
+ proc_create("ppc64/rtas/rmo_buffer", S_IRUSR, NULL,
+ &ppc_rtas_rmo_buf_ops);
return 0;
}
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c
index e1756e1..d32bfe4 100644
--- a/arch/powerpc/kernel/rtas_flash.c
+++ b/arch/powerpc/kernel/rtas_flash.c
@@ -704,18 +704,11 @@ static int initialize_flash_pde_data(const char *rtas_call_name,
static struct proc_dir_entry *create_flash_pde(const char *filename,
const struct file_operations *fops)
{
- struct proc_dir_entry *ent = NULL;
-
- ent = create_proc_entry(filename, S_IRUSR | S_IWUSR, NULL);
- if (ent != NULL) {
- ent->proc_fops = fops;
- ent->owner = THIS_MODULE;
- }
-
- return ent;
+ return proc_create(filename, S_IRUSR | S_IWUSR, NULL, fops);
}
static const struct file_operations rtas_flash_operations = {
+ .owner = THIS_MODULE,
.read = rtas_flash_read,
.write = rtas_flash_write,
.open = rtas_excl_open,
@@ -723,6 +716,7 @@ static const struct file_operations rtas_flash_operations = {
};
static const struct file_operations manage_flash_operations = {
+ .owner = THIS_MODULE,
.read = manage_flash_read,
.write = manage_flash_write,
.open = rtas_excl_open,
@@ -730,6 +724,7 @@ static const struct file_operations manage_flash_operations = {
};
static const struct file_operations validate_flash_operations = {
+ .owner = THIS_MODULE,
.read = validate_flash_read,
.write = validate_flash_write,
.open = rtas_excl_open,
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
index 00528ef..45dcd26 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -1063,10 +1063,9 @@ int __init spu_sched_init(void)
mod_timer(&spuloadavg_timer, 0);
- entry = create_proc_entry("spu_loadavg", 0, NULL);
+ entry = proc_create("spu_loadavg", 0, NULL, &spu_loadavg_fops);
if (!entry)
goto out_stop_kthread;
- entry->proc_fops = &spu_loadavg_fops;
pr_debug("spusched: tick: %d, min ticks: %d, default ticks: %d\n",
SPUSCHED_TICK, MIN_SPU_TIMESLICE, DEF_SPU_TIMESLICE);
diff --git a/arch/powerpc/platforms/cell/spufs/sputrace.c b/arch/powerpc/platforms/cell/spufs/sputrace.c
index 79aa773..aea5286 100644
--- a/arch/powerpc/platforms/cell/spufs/sputrace.c
+++ b/arch/powerpc/platforms/cell/spufs/sputrace.c
@@ -201,10 +201,9 @@ static int __init sputrace_init(void)
if (!sputrace_log)
goto out;
- entry = create_proc_entry("sputrace", S_IRUSR, NULL);
+ entry = proc_create("sputrace", S_IRUSR, NULL, &sputrace_fops);
if (!entry)
goto out_free_log;
- entry->proc_fops = &sputrace_fops;
for (i = 0; i < ARRAY_SIZE(spu_probes); i++) {
struct spu_probe *p = &spu_probes[i];
diff --git a/arch/powerpc/platforms/iseries/lpevents.c b/arch/powerpc/platforms/iseries/lpevents.c
index e5b40e3..b0f8a85 100644
--- a/arch/powerpc/platforms/iseries/lpevents.c
+++ b/arch/powerpc/platforms/iseries/lpevents.c
@@ -330,15 +330,11 @@ static const struct file_operations proc_lpevents_operations = {
static int __init proc_lpevents_init(void)
{
- struct proc_dir_entry *e;
-
if (!firmware_has_feature(FW_FEATURE_ISERIES))
return 0;
- e = create_proc_entry("iSeries/lpevents", S_IFREG|S_IRUGO, NULL);
- if (e)
- e->proc_fops = &proc_lpevents_operations;
-
+ proc_create("iSeries/lpevents", S_IFREG|S_IRUGO, NULL,
+ &proc_lpevents_operations);
return 0;
}
__initcall(proc_lpevents_init);
diff --git a/arch/powerpc/platforms/iseries/mf.c b/arch/powerpc/platforms/iseries/mf.c
index c0f2433..1dc7295 100644
--- a/arch/powerpc/platforms/iseries/mf.c
+++ b/arch/powerpc/platforms/iseries/mf.c
@@ -1255,11 +1255,11 @@ static int __init mf_proc_init(void)
if (i == 3) /* no vmlinux entry for 'D' */
continue;
- ent = create_proc_entry("vmlinux", S_IFREG|S_IWUSR, mf);
+ ent = proc_create_data("vmlinux", S_IFREG|S_IWUSR, mf,
+ &proc_vmlinux_operations,
+ (void *)(long)i);
if (!ent)
return 1;
- ent->data = (void *)(long)i;
- ent->proc_fops = &proc_vmlinux_operations;
}
ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
diff --git a/arch/powerpc/platforms/iseries/proc.c b/arch/powerpc/platforms/iseries/proc.c
index f2cde41..91f4c6c 100644
--- a/arch/powerpc/platforms/iseries/proc.c
+++ b/arch/powerpc/platforms/iseries/proc.c
@@ -110,15 +110,11 @@ static const struct file_operations proc_titantod_operations = {
static int __init iseries_proc_init(void)
{
- struct proc_dir_entry *e;
-
if (!firmware_has_feature(FW_FEATURE_ISERIES))
return 0;
- e = create_proc_entry("iSeries/titanTod", S_IFREG|S_IRUGO, NULL);
- if (e)
- e->proc_fops = &proc_titantod_operations;
-
+ proc_create("iSeries/titanTod", S_IFREG|S_IRUGO, NULL,
+ &proc_titantod_operations);
return 0;
}
__initcall(iseries_proc_init);
diff --git a/arch/powerpc/platforms/iseries/viopath.c b/arch/powerpc/platforms/iseries/viopath.c
index df23331..49ff4dc 100644
--- a/arch/powerpc/platforms/iseries/viopath.c
+++ b/arch/powerpc/platforms/iseries/viopath.c
@@ -180,15 +180,10 @@ static const struct file_operations proc_viopath_operations = {
static int __init vio_proc_init(void)
{
- struct proc_dir_entry *e;
-
if (!firmware_has_feature(FW_FEATURE_ISERIES))
return 0;
- e = create_proc_entry("iSeries/config", 0, NULL);
- if (e)
- e->proc_fops = &proc_viopath_operations;
-
+ proc_create("iSeries/config", 0, NULL, &proc_viopath_operations);
return 0;
}
__initcall(vio_proc_init);
diff --git a/arch/powerpc/platforms/pseries/eeh.c b/arch/powerpc/platforms/pseries/eeh.c
index 9eb539e..d6df95b 100644
--- a/arch/powerpc/platforms/pseries/eeh.c
+++ b/arch/powerpc/platforms/pseries/eeh.c
@@ -1261,14 +1261,8 @@ static const struct file_operations proc_eeh_operations = {
static int __init eeh_init_proc(void)
{
- struct proc_dir_entry *e;
-
- if (machine_is(pseries)) {
- e = create_proc_entry("ppc64/eeh", 0, NULL);
- if (e)
- e->proc_fops = &proc_eeh_operations;
- }
-
+ if (machine_is(pseries))
+ proc_create("ppc64/eeh", 0, NULL, &proc_eeh_operations);
return 0;
}
__initcall(eeh_init_proc);
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
index ac75c10..75769aa 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -512,12 +512,9 @@ static int proc_ppc64_create_ofdt(void)
if (!machine_is(pseries))
return 0;
- ent = create_proc_entry("ppc64/ofdt", S_IWUSR, NULL);
- if (ent) {
- ent->data = NULL;
+ ent = proc_create("ppc64/ofdt", S_IWUSR, NULL, &ofdt_fops);
+ if (ent)
ent->size = 0;
- ent->proc_fops = &ofdt_fops;
- }
return 0;
}
diff --git a/arch/powerpc/platforms/pseries/rtasd.c b/arch/powerpc/platforms/pseries/rtasd.c
index e3078ce..bc2883c 100644
--- a/arch/powerpc/platforms/pseries/rtasd.c
+++ b/arch/powerpc/platforms/pseries/rtasd.c
@@ -472,10 +472,9 @@ static int __init rtas_init(void)
return -ENOMEM;
}
- entry = create_proc_entry("ppc64/rtas/error_log", S_IRUSR, NULL);
- if (entry)
- entry->proc_fops = &proc_rtas_log_operations;
- else
+ entry = proc_create("ppc64/rtas/error_log", S_IRUSR, NULL,
+ &proc_rtas_log_operations);
+ if (!entry)
printk(KERN_ERR "Failed to create error_log proc entry\n");
if (kernel_thread(rtasd, NULL, CLONE_FS) < 0)
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 23/29] acpi: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (21 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 22/29] powerpc: use non-racy method for proc entries creation Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 24/29] net: " Denis V. Lunev
` (5 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
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: linux-acpi@vger.kernel.org
---
drivers/acpi/ac.c | 12 +---
drivers/acpi/battery.c | 12 ++--
drivers/acpi/button.c | 24 +++----
drivers/acpi/ec.c | 11 +---
drivers/acpi/event.c | 8 +-
drivers/acpi/fan.c | 14 ++---
drivers/acpi/power.c | 11 +--
drivers/acpi/processor_core.c | 39 +++++--------
drivers/acpi/processor_idle.c | 13 ++---
drivers/acpi/processor_perflib.c | 13 +---
drivers/acpi/processor_thermal.c | 1 +
drivers/acpi/processor_throttling.c | 1 +
drivers/acpi/sbs.c | 35 +++--------
drivers/acpi/sleep/proc.c | 26 +++-----
drivers/acpi/system.c | 27 ++++-----
drivers/acpi/thermal.c | 67 +++++++++------------
drivers/acpi/video.c | 112 ++++++++++++++---------------------
17 files changed, 162 insertions(+), 264 deletions(-)
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 76b9bea..ab6b7ac 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -92,6 +92,7 @@ struct acpi_ac {
#ifdef CONFIG_ACPI_PROCFS_POWER
static const struct file_operations acpi_ac_fops = {
+ .owner = THIS_MODULE,
.open = acpi_ac_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -195,16 +196,11 @@ static int acpi_ac_add_fs(struct acpi_device *device)
}
/* 'state' [R] */
- entry = create_proc_entry(ACPI_AC_FILE_STATE,
- S_IRUGO, acpi_device_dir(device));
+ entry = proc_create_data(ACPI_AC_FILE_STATE,
+ S_IRUGO, acpi_device_dir(device),
+ &acpi_ac_fops, acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- entry->proc_fops = &acpi_ac_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
-
return 0;
}
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index d5729d5..b1c723f 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -741,15 +741,13 @@ static int acpi_battery_add_fs(struct acpi_device *device)
}
for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) {
- entry = create_proc_entry(acpi_battery_file[i].name,
- acpi_battery_file[i].mode, acpi_device_dir(device));
+ entry = proc_create_data(acpi_battery_file[i].name,
+ acpi_battery_file[i].mode,
+ acpi_device_dir(device),
+ &acpi_battery_file[i].ops,
+ acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- entry->proc_fops = &acpi_battery_file[i].ops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
}
return 0;
}
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 6c5da83..1dfec41 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -102,6 +102,7 @@ struct acpi_button {
};
static const struct file_operations acpi_button_info_fops = {
+ .owner = THIS_MODULE,
.open = acpi_button_info_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -109,6 +110,7 @@ static const struct file_operations acpi_button_info_fops = {
};
static const struct file_operations acpi_button_state_fops = {
+ .owner = THIS_MODULE,
.open = acpi_button_state_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -207,27 +209,21 @@ static int acpi_button_add_fs(struct acpi_device *device)
acpi_device_dir(device)->owner = THIS_MODULE;
/* 'info' [R] */
- entry = create_proc_entry(ACPI_BUTTON_FILE_INFO,
- S_IRUGO, acpi_device_dir(device));
+ entry = proc_create_data(ACPI_BUTTON_FILE_INFO,
+ S_IRUGO, acpi_device_dir(device),
+ &acpi_button_info_fops,
+ acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- entry->proc_fops = &acpi_button_info_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
/* show lid state [R] */
if (button->type == ACPI_BUTTON_TYPE_LID) {
- entry = create_proc_entry(ACPI_BUTTON_FILE_STATE,
- S_IRUGO, acpi_device_dir(device));
+ entry = proc_create_data(ACPI_BUTTON_FILE_STATE,
+ S_IRUGO, acpi_device_dir(device),
+ &acpi_button_state_fops,
+ acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- entry->proc_fops = &acpi_button_state_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
}
return 0;
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 3d93621..0924992 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -634,16 +634,11 @@ static int acpi_ec_add_fs(struct acpi_device *device)
return -ENODEV;
}
- entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
- acpi_device_dir(device));
+ entry = proc_create_data(ACPI_EC_FILE_INFO, S_IRUGO,
+ acpi_device_dir(device),
+ &acpi_ec_info_ops, acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- entry->proc_fops = &acpi_ec_info_ops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
-
return 0;
}
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index abec1ca..0c24bd4 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -102,6 +102,7 @@ static unsigned int acpi_system_poll_event(struct file *file, poll_table * wait)
}
static const struct file_operations acpi_system_event_ops = {
+ .owner = THIS_MODULE,
.open = acpi_system_open_event,
.read = acpi_system_read_event,
.release = acpi_system_close_event,
@@ -294,10 +295,9 @@ static int __init acpi_event_init(void)
#ifdef CONFIG_ACPI_PROC_EVENT
/* 'event' [R] */
- entry = create_proc_entry("event", S_IRUSR, acpi_root_dir);
- if (entry)
- entry->proc_fops = &acpi_system_event_ops;
- else
+ entry = proc_create("event", S_IRUSR, acpi_root_dir,
+ &acpi_system_event_ops);
+ if (!entry)
return -ENODEV;
#endif
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index c8e3cba..194077a 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -192,17 +192,13 @@ static int acpi_fan_add_fs(struct acpi_device *device)
}
/* 'status' [R/W] */
- entry = create_proc_entry(ACPI_FAN_FILE_STATE,
- S_IFREG | S_IRUGO | S_IWUSR,
- acpi_device_dir(device));
+ entry = proc_create_data(ACPI_FAN_FILE_STATE,
+ S_IFREG | S_IRUGO | S_IWUSR,
+ acpi_device_dir(device),
+ &acpi_fan_state_ops,
+ device);
if (!entry)
return -ENODEV;
- else {
- entry->proc_fops = &acpi_fan_state_ops;
- entry->data = device;
- entry->owner = THIS_MODULE;
- }
-
return 0;
}
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 76bf6d9..21fc8bf 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -93,6 +93,7 @@ struct acpi_power_resource {
static struct list_head acpi_power_resource_list;
static const struct file_operations acpi_power_fops = {
+ .owner = THIS_MODULE,
.open = acpi_power_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -543,15 +544,11 @@ static int acpi_power_add_fs(struct acpi_device *device)
}
/* 'status' [R] */
- entry = create_proc_entry(ACPI_POWER_FILE_STATUS,
- S_IRUGO, acpi_device_dir(device));
+ entry = proc_create_data(ACPI_POWER_FILE_STATUS,
+ S_IRUGO, acpi_device_dir(device),
+ &acpi_power_fops, acpi_driver_data(device));
if (!entry)
return -EIO;
- else {
- entry->proc_fops = &acpi_power_fops;
- entry->data = acpi_driver_data(device);
- }
-
return 0;
}
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 3015330..6e68e3f 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -112,6 +112,7 @@ static struct acpi_driver acpi_processor_driver = {
#define UNINSTALL_NOTIFY_HANDLER 2
static const struct file_operations acpi_processor_info_fops = {
+ .owner = THIS_MODULE,
.open = acpi_processor_info_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -326,40 +327,30 @@ static int acpi_processor_add_fs(struct acpi_device *device)
acpi_device_dir(device)->owner = THIS_MODULE;
/* 'info' [R] */
- entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO,
- S_IRUGO, acpi_device_dir(device));
+ entry = proc_create_data(ACPI_PROCESSOR_FILE_INFO,
+ S_IRUGO, acpi_device_dir(device),
+ &acpi_processor_info_fops,
+ acpi_driver_data(device));
if (!entry)
return -EIO;
- else {
- entry->proc_fops = &acpi_processor_info_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
/* 'throttling' [R/W] */
- entry = create_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING,
- S_IFREG | S_IRUGO | S_IWUSR,
- acpi_device_dir(device));
+ entry = proc_create_data(ACPI_PROCESSOR_FILE_THROTTLING,
+ S_IFREG | S_IRUGO | S_IWUSR,
+ acpi_device_dir(device),
+ &acpi_processor_throttling_fops,
+ acpi_driver_data(device));
if (!entry)
return -EIO;
- else {
- entry->proc_fops = &acpi_processor_throttling_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
/* 'limit' [R/W] */
- entry = create_proc_entry(ACPI_PROCESSOR_FILE_LIMIT,
- S_IFREG | S_IRUGO | S_IWUSR,
- acpi_device_dir(device));
+ entry = proc_create_data(ACPI_PROCESSOR_FILE_LIMIT,
+ S_IFREG | S_IRUGO | S_IWUSR,
+ acpi_device_dir(device),
+ &acpi_processor_limit_fops,
+ acpi_driver_data(device));
if (!entry)
return -EIO;
- else {
- entry->proc_fops = &acpi_processor_limit_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
-
return 0;
}
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 5f91ad3..b0c8584 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -1302,6 +1302,7 @@ static int acpi_processor_power_open_fs(struct inode *inode, struct file *file)
}
static const struct file_operations acpi_processor_power_fops = {
+ .owner = THIS_MODULE,
.open = acpi_processor_power_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -1842,16 +1843,12 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
}
/* 'power' [R] */
- entry = create_proc_entry(ACPI_PROCESSOR_FILE_POWER,
- S_IRUGO, acpi_device_dir(device));
+ entry = proc_create_data(ACPI_PROCESSOR_FILE_POWER,
+ S_IRUGO, acpi_device_dir(device),
+ &acpi_processor_power_fops,
+ acpi_driver_data(device));
if (!entry)
return -EIO;
- else {
- entry->proc_fops = &acpi_processor_power_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
-
return 0;
}
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 3f3ab11..b474996 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -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;
}
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index 649ae99..ef34b18 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -509,6 +509,7 @@ static ssize_t acpi_processor_write_limit(struct file * file,
}
struct file_operations acpi_processor_limit_fops = {
+ .owner = THIS_MODULE,
.open = acpi_processor_limit_open_fs,
.read = seq_read,
.write = acpi_processor_write_limit,
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 117cda6..b4cd47c 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -1252,6 +1252,7 @@ static ssize_t acpi_processor_write_throttling(struct file *file,
}
struct file_operations acpi_processor_throttling_fops = {
+ .owner = THIS_MODULE,
.open = acpi_processor_throttling_open_fs,
.read = seq_read,
.write = acpi_processor_write_throttling,
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 585ae3c..10a3651 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -483,8 +483,6 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir,
struct file_operations *state_fops,
struct file_operations *alarm_fops, void *data)
{
- struct proc_dir_entry *entry = NULL;
-
if (!*dir) {
*dir = proc_mkdir(dir_name, parent_dir);
if (!*dir) {
@@ -494,34 +492,19 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir,
}
/* 'info' [R] */
- if (info_fops) {
- entry = create_proc_entry(ACPI_SBS_FILE_INFO, S_IRUGO, *dir);
- if (entry) {
- entry->proc_fops = info_fops;
- entry->data = data;
- entry->owner = THIS_MODULE;
- }
- }
+ if (info_fops)
+ proc_create_data(ACPI_SBS_FILE_INFO, S_IRUGO, *dir,
+ info_fops, data);
/* 'state' [R] */
- if (state_fops) {
- entry = create_proc_entry(ACPI_SBS_FILE_STATE, S_IRUGO, *dir);
- if (entry) {
- entry->proc_fops = state_fops;
- entry->data = data;
- entry->owner = THIS_MODULE;
- }
- }
+ if (state_fops)
+ proc_create_data(ACPI_SBS_FILE_STATE, S_IRUGO, *dir,
+ state_fops, data);
/* 'alarm' [R/W] */
- if (alarm_fops) {
- entry = create_proc_entry(ACPI_SBS_FILE_ALARM, S_IRUGO, *dir);
- if (entry) {
- entry->proc_fops = alarm_fops;
- entry->data = data;
- entry->owner = THIS_MODULE;
- }
- }
+ if (alarm_fops)
+ proc_create_data(ACPI_SBS_FILE_ALARM, S_IRUGO, *dir,
+ alarm_fops, data);
return 0;
}
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
index f8df521..8a5fe87 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/sleep/proc.c
@@ -440,6 +440,7 @@ acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file)
}
static const struct file_operations acpi_system_wakeup_device_fops = {
+ .owner = THIS_MODULE,
.open = acpi_system_wakeup_device_open_fs,
.read = seq_read,
.write = acpi_system_write_wakeup_device,
@@ -449,6 +450,7 @@ static const struct file_operations acpi_system_wakeup_device_fops = {
#ifdef CONFIG_ACPI_PROCFS
static const struct file_operations acpi_system_sleep_fops = {
+ .owner = THIS_MODULE,
.open = acpi_system_sleep_open_fs,
.read = seq_read,
.write = acpi_system_write_sleep,
@@ -459,6 +461,7 @@ static const struct file_operations acpi_system_sleep_fops = {
#ifdef HAVE_ACPI_LEGACY_ALARM
static const struct file_operations acpi_system_alarm_fops = {
+ .owner = THIS_MODULE,
.open = acpi_system_alarm_open_fs,
.read = seq_read,
.write = acpi_system_write_alarm,
@@ -477,37 +480,26 @@ static u32 rtc_handler(void *context)
static int __init acpi_sleep_proc_init(void)
{
- struct proc_dir_entry *entry = NULL;
-
if (acpi_disabled)
return 0;
#ifdef CONFIG_ACPI_PROCFS
/* 'sleep' [R/W] */
- entry =
- create_proc_entry("sleep", S_IFREG | S_IRUGO | S_IWUSR,
- acpi_root_dir);
- if (entry)
- entry->proc_fops = &acpi_system_sleep_fops;
+ proc_create("sleep", S_IFREG | S_IRUGO | S_IWUSR,
+ acpi_root_dir, &acpi_system_sleep_fops);
#endif /* CONFIG_ACPI_PROCFS */
#ifdef HAVE_ACPI_LEGACY_ALARM
/* 'alarm' [R/W] */
- entry =
- create_proc_entry("alarm", S_IFREG | S_IRUGO | S_IWUSR,
- acpi_root_dir);
- if (entry)
- entry->proc_fops = &acpi_system_alarm_fops;
+ proc_create("alarm", S_IFREG | S_IRUGO | S_IWUSR,
+ acpi_root_dir, &acpi_system_alarm_fops);
acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL);
#endif /* HAVE_ACPI_LEGACY_ALARM */
/* 'wakeup device' [R/W] */
- entry =
- create_proc_entry("wakeup", S_IFREG | S_IRUGO | S_IWUSR,
- acpi_root_dir);
- if (entry)
- entry->proc_fops = &acpi_system_wakeup_device_fops;
+ proc_create("wakeup", S_IFREG | S_IRUGO | S_IWUSR,
+ acpi_root_dir, &acpi_system_wakeup_device_fops);
return 0;
}
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index 4749f37..769f248 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -396,6 +396,7 @@ static int acpi_system_info_open_fs(struct inode *inode, struct file *file)
}
static const struct file_operations acpi_system_info_ops = {
+ .owner = THIS_MODULE,
.open = acpi_system_info_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -406,6 +407,7 @@ static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t,
loff_t *);
static const struct file_operations acpi_system_dsdt_ops = {
+ .owner = THIS_MODULE,
.read = acpi_system_read_dsdt,
};
@@ -430,6 +432,7 @@ static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t,
loff_t *);
static const struct file_operations acpi_system_fadt_ops = {
+ .owner = THIS_MODULE,
.read = acpi_system_read_fadt,
};
@@ -454,31 +457,23 @@ static int acpi_system_procfs_init(void)
{
struct proc_dir_entry *entry;
int error = 0;
- char *name;
/* 'info' [R] */
- name = ACPI_SYSTEM_FILE_INFO;
- entry = create_proc_entry(name, S_IRUGO, acpi_root_dir);
+ entry = proc_create(ACPI_SYSTEM_FILE_INFO, S_IRUGO, acpi_root_dir,
+ &acpi_system_info_ops);
if (!entry)
goto Error;
- else {
- entry->proc_fops = &acpi_system_info_ops;
- }
/* 'dsdt' [R] */
- name = ACPI_SYSTEM_FILE_DSDT;
- entry = create_proc_entry(name, S_IRUSR, acpi_root_dir);
- if (entry)
- entry->proc_fops = &acpi_system_dsdt_ops;
- else
+ entry = proc_create(ACPI_SYSTEM_FILE_DSDT, S_IRUSR, acpi_root_dir,
+ &acpi_system_dsdt_ops);
+ if (!entry)
goto Error;
/* 'fadt' [R] */
- name = ACPI_SYSTEM_FILE_FADT;
- entry = create_proc_entry(name, S_IRUSR, acpi_root_dir);
- if (entry)
- entry->proc_fops = &acpi_system_fadt_ops;
- else
+ entry = proc_create(ACPI_SYSTEM_FILE_FADT, S_IRUSR, acpi_root_dir,
+ &acpi_system_fadt_ops);
+ if (!entry)
goto Error;
Done:
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 921d0f7..d18c4dd 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -198,6 +198,7 @@ struct acpi_thermal {
};
static const struct file_operations acpi_thermal_state_fops = {
+ .owner = THIS_MODULE,
.open = acpi_thermal_state_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -205,6 +206,7 @@ static const struct file_operations acpi_thermal_state_fops = {
};
static const struct file_operations acpi_thermal_temp_fops = {
+ .owner = THIS_MODULE,
.open = acpi_thermal_temp_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -212,6 +214,7 @@ static const struct file_operations acpi_thermal_temp_fops = {
};
static const struct file_operations acpi_thermal_trip_fops = {
+ .owner = THIS_MODULE,
.open = acpi_thermal_trip_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -219,6 +222,7 @@ static const struct file_operations acpi_thermal_trip_fops = {
};
static const struct file_operations acpi_thermal_cooling_fops = {
+ .owner = THIS_MODULE,
.open = acpi_thermal_cooling_open_fs,
.read = seq_read,
.write = acpi_thermal_write_cooling_mode,
@@ -227,6 +231,7 @@ static const struct file_operations acpi_thermal_cooling_fops = {
};
static const struct file_operations acpi_thermal_polling_fops = {
+ .owner = THIS_MODULE,
.open = acpi_thermal_polling_open_fs,
.read = seq_read,
.write = acpi_thermal_write_polling,
@@ -1419,63 +1424,47 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
}
/* 'state' [R] */
- entry = create_proc_entry(ACPI_THERMAL_FILE_STATE,
- S_IRUGO, acpi_device_dir(device));
+ entry = proc_create_data(ACPI_THERMAL_FILE_STATE,
+ S_IRUGO, acpi_device_dir(device),
+ &acpi_thermal_state_fops,
+ acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- entry->proc_fops = &acpi_thermal_state_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
/* 'temperature' [R] */
- entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE,
- S_IRUGO, acpi_device_dir(device));
+ entry = proc_create_data(ACPI_THERMAL_FILE_TEMPERATURE,
+ S_IRUGO, acpi_device_dir(device),
+ &acpi_thermal_temp_fops,
+ acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- entry->proc_fops = &acpi_thermal_temp_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
/* 'trip_points' [R] */
- entry = create_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS,
- S_IRUGO,
- acpi_device_dir(device));
+ entry = proc_create_data(ACPI_THERMAL_FILE_TRIP_POINTS,
+ S_IRUGO,
+ acpi_device_dir(device),
+ &acpi_thermal_trip_fops,
+ acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- entry->proc_fops = &acpi_thermal_trip_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
/* 'cooling_mode' [R/W] */
- entry = create_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE,
- S_IFREG | S_IRUGO | S_IWUSR,
- acpi_device_dir(device));
+ entry = proc_create_data(ACPI_THERMAL_FILE_COOLING_MODE,
+ S_IFREG | S_IRUGO | S_IWUSR,
+ acpi_device_dir(device),
+ &acpi_thermal_cooling_fops,
+ acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- entry->proc_fops = &acpi_thermal_cooling_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
/* 'polling_frequency' [R/W] */
- entry = create_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ,
- S_IFREG | S_IRUGO | S_IWUSR,
- acpi_device_dir(device));
+ entry = proc_create_data(ACPI_THERMAL_FILE_POLLING_FREQ,
+ S_IFREG | S_IRUGO | S_IWUSR,
+ acpi_device_dir(device),
+ &acpi_thermal_polling_fops,
+ acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- entry->proc_fops = &acpi_thermal_polling_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
-
return 0;
}
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 12fb44f..0fc952d 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -192,6 +192,7 @@ struct acpi_video_device {
/* bus */
static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file);
static struct file_operations acpi_video_bus_info_fops = {
+ .owner = THIS_MODULE,
.open = acpi_video_bus_info_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -200,6 +201,7 @@ static struct file_operations acpi_video_bus_info_fops = {
static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file);
static struct file_operations acpi_video_bus_ROM_fops = {
+ .owner = THIS_MODULE,
.open = acpi_video_bus_ROM_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -209,6 +211,7 @@ static struct file_operations acpi_video_bus_ROM_fops = {
static int acpi_video_bus_POST_info_open_fs(struct inode *inode,
struct file *file);
static struct file_operations acpi_video_bus_POST_info_fops = {
+ .owner = THIS_MODULE,
.open = acpi_video_bus_POST_info_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -217,6 +220,7 @@ static struct file_operations acpi_video_bus_POST_info_fops = {
static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file);
static struct file_operations acpi_video_bus_POST_fops = {
+ .owner = THIS_MODULE,
.open = acpi_video_bus_POST_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -225,6 +229,7 @@ static struct file_operations acpi_video_bus_POST_fops = {
static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file);
static struct file_operations acpi_video_bus_DOS_fops = {
+ .owner = THIS_MODULE,
.open = acpi_video_bus_DOS_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -235,6 +240,7 @@ static struct file_operations acpi_video_bus_DOS_fops = {
static int acpi_video_device_info_open_fs(struct inode *inode,
struct file *file);
static struct file_operations acpi_video_device_info_fops = {
+ .owner = THIS_MODULE,
.open = acpi_video_device_info_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -244,6 +250,7 @@ static struct file_operations acpi_video_device_info_fops = {
static int acpi_video_device_state_open_fs(struct inode *inode,
struct file *file);
static struct file_operations acpi_video_device_state_fops = {
+ .owner = THIS_MODULE,
.open = acpi_video_device_state_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -253,6 +260,7 @@ static struct file_operations acpi_video_device_state_fops = {
static int acpi_video_device_brightness_open_fs(struct inode *inode,
struct file *file);
static struct file_operations acpi_video_device_brightness_fops = {
+ .owner = THIS_MODULE,
.open = acpi_video_device_brightness_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -262,6 +270,7 @@ static struct file_operations acpi_video_device_brightness_fops = {
static int acpi_video_device_EDID_open_fs(struct inode *inode,
struct file *file);
static struct file_operations acpi_video_device_EDID_fops = {
+ .owner = THIS_MODULE,
.open = acpi_video_device_EDID_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -1070,51 +1079,36 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
}
/* 'info' [R] */
- entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
+ entry = proc_create_data("info", S_IRUGO, acpi_device_dir(device),
+ &acpi_video_device_info_fops, acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- entry->proc_fops = &acpi_video_device_info_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
/* 'state' [R/W] */
- entry =
- create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR,
- acpi_device_dir(device));
+ acpi_video_device_state_fops.write = acpi_video_device_write_state;
+ entry = proc_create_data("state", S_IFREG | S_IRUGO | S_IWUSR,
+ acpi_device_dir(device),
+ &acpi_video_device_state_fops,
+ acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- acpi_video_device_state_fops.write = acpi_video_device_write_state;
- entry->proc_fops = &acpi_video_device_state_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
/* 'brightness' [R/W] */
- entry =
- create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR,
- acpi_device_dir(device));
+ acpi_video_device_brightness_fops.write =
+ acpi_video_device_write_brightness;
+ entry = proc_create_data("brightness", S_IFREG | S_IRUGO | S_IWUSR,
+ acpi_device_dir(device),
+ &acpi_video_device_brightness_fops,
+ acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- acpi_video_device_brightness_fops.write = acpi_video_device_write_brightness;
- entry->proc_fops = &acpi_video_device_brightness_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
/* 'EDID' [R] */
- entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device));
+ entry = proc_create_data("EDID", S_IRUGO, acpi_device_dir(device),
+ &acpi_video_device_EDID_fops,
+ acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- entry->proc_fops = &acpi_video_device_EDID_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
-
return 0;
}
@@ -1353,61 +1347,43 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
}
/* 'info' [R] */
- entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
+ entry = proc_create_data("info", S_IRUGO, acpi_device_dir(device),
+ &acpi_video_bus_info_fops,
+ acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- entry->proc_fops = &acpi_video_bus_info_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
/* 'ROM' [R] */
- entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device));
+ entry = proc_create_data("ROM", S_IRUGO, acpi_device_dir(device),
+ &acpi_video_bus_ROM_fops,
+ acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- entry->proc_fops = &acpi_video_bus_ROM_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
/* 'POST_info' [R] */
- entry =
- create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device));
+ entry = proc_create_data("POST_info", S_IRUGO, acpi_device_dir(device),
+ &acpi_video_bus_POST_info_fops,
+ acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- entry->proc_fops = &acpi_video_bus_POST_info_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
/* 'POST' [R/W] */
- entry =
- create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR,
- acpi_device_dir(device));
+ acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST;
+ entry = proc_create_data("POST", S_IFREG | S_IRUGO | S_IRUSR,
+ acpi_device_dir(device),
+ &acpi_video_bus_POST_fops,
+ acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST;
- entry->proc_fops = &acpi_video_bus_POST_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
/* 'DOS' [R/W] */
- entry =
- create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR,
- acpi_device_dir(device));
+ acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS;
+ entry = proc_create_data("DOS", S_IFREG | S_IRUGO | S_IRUSR,
+ acpi_device_dir(device),
+ &acpi_video_bus_DOS_fops,
+ acpi_driver_data(device));
if (!entry)
return -ENODEV;
- else {
- acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS;
- entry->proc_fops = &acpi_video_bus_DOS_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
return 0;
}
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 24/29] net: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (22 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 23/29] acpi: " Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 25/29] isdn: " Denis V. Lunev
` (4 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create()/proc_create_data() to make sure that ->proc_fops and
->data be setup before gluing PDE to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Jeff Garzik <jgarzik@pobox.com>
---
drivers/net/bonding/bond_main.c | 9 +---
drivers/net/ibmveth.c | 9 +---
drivers/net/irda/vlsi_ir.c | 5 +-
drivers/net/pppoe.c | 4 +-
drivers/net/pppol2tp.c | 4 +-
drivers/net/wireless/airo.c | 84 +++++++++++++++------------------------
6 files changed, 43 insertions(+), 72 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index ecfaf14..fb47448 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3284,17 +3284,14 @@ static int bond_create_proc_entry(struct bonding *bond)
struct net_device *bond_dev = bond->dev;
if (bond_proc_dir) {
- bond->proc_entry = create_proc_entry(bond_dev->name,
- S_IRUGO,
- bond_proc_dir);
+ bond->proc_entry = proc_create_data(bond_dev->name,
+ S_IRUGO, bond_proc_dir,
+ &bond_info_fops, bond);
if (bond->proc_entry == NULL) {
printk(KERN_WARNING DRV_NAME
": Warning: Cannot create /proc/net/%s/%s\n",
DRV_NAME, bond_dev->name);
} else {
- bond->proc_entry->data = bond;
- bond->proc_entry->proc_fops = &bond_info_fops;
- bond->proc_entry->owner = THIS_MODULE;
memcpy(bond->proc_file_name, bond_dev->name, IFNAMSIZ);
}
}
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index bb31e09..a99a3ae 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -1303,13 +1303,10 @@ static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter)
if (ibmveth_proc_dir) {
char u_addr[10];
sprintf(u_addr, "%x", adapter->vdev->unit_address);
- entry = create_proc_entry(u_addr, S_IFREG, ibmveth_proc_dir);
- if (!entry) {
+ entry = proc_create_data(u_addr, S_IFREG, ibmveth_proc_dir,
+ &ibmveth_proc_fops, adapter);
+ if (!entry)
ibmveth_error_printk("Cannot create adapter proc entry");
- } else {
- entry->data = (void *) adapter;
- entry->proc_fops = &ibmveth_proc_fops;
- }
}
return;
}
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
index acd082a..d15e00b 100644
--- a/drivers/net/irda/vlsi_ir.c
+++ b/drivers/net/irda/vlsi_ir.c
@@ -1674,13 +1674,12 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id)
if (vlsi_proc_root != NULL) {
struct proc_dir_entry *ent;
- ent = create_proc_entry(ndev->name, S_IFREG|S_IRUGO, vlsi_proc_root);
+ ent = proc_create_data(ndev->name, S_IFREG|S_IRUGO,
+ vlsi_proc_root, VLSI_PROC_FOPS, ndev);
if (!ent) {
IRDA_WARNING("%s: failed to create proc entry\n",
__FUNCTION__);
} else {
- ent->data = ndev;
- ent->proc_fops = VLSI_PROC_FOPS;
ent->size = 0;
}
idev->proc_entry = ent;
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index 4fad4dd..58a26a4 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -1052,11 +1052,9 @@ static int __init pppoe_proc_init(void)
{
struct proc_dir_entry *p;
- p = create_proc_entry("pppoe", S_IRUGO, init_net.proc_net);
+ p = proc_net_fops_create(&init_net, "pppoe", S_IRUGO, &pppoe_seq_fops);
if (!p)
return -ENOMEM;
-
- p->proc_fops = &pppoe_seq_fops;
return 0;
}
#else /* CONFIG_PROC_FS */
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c
index 3d10ca0..244d783 100644
--- a/drivers/net/pppol2tp.c
+++ b/drivers/net/pppol2tp.c
@@ -2469,12 +2469,12 @@ static int __init pppol2tp_init(void)
goto out_unregister_pppol2tp_proto;
#ifdef CONFIG_PROC_FS
- pppol2tp_proc = create_proc_entry("pppol2tp", 0, init_net.proc_net);
+ pppol2tp_proc = proc_net_fops_create(&init_net, "pppol2tp", 0,
+ &pppol2tp_proc_fops);
if (!pppol2tp_proc) {
err = -ENOMEM;
goto out_unregister_pppox_proto;
}
- pppol2tp_proc->proc_fops = &pppol2tp_proc_fops;
#endif /* CONFIG_PROC_FS */
printk(KERN_INFO "PPPoL2TP kernel driver, %s\n",
PPPOL2TP_DRV_VERSION);
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 6c395fc..d263eee 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -4347,24 +4347,28 @@ static int proc_config_open( struct inode *inode, struct file *file );
static int proc_wepkey_open( struct inode *inode, struct file *file );
static const struct file_operations proc_statsdelta_ops = {
+ .owner = THIS_MODULE,
.read = proc_read,
.open = proc_statsdelta_open,
.release = proc_close
};
static const struct file_operations proc_stats_ops = {
+ .owner = THIS_MODULE,
.read = proc_read,
.open = proc_stats_open,
.release = proc_close
};
static const struct file_operations proc_status_ops = {
+ .owner = THIS_MODULE,
.read = proc_read,
.open = proc_status_open,
.release = proc_close
};
static const struct file_operations proc_SSID_ops = {
+ .owner = THIS_MODULE,
.read = proc_read,
.write = proc_write,
.open = proc_SSID_open,
@@ -4372,6 +4376,7 @@ static const struct file_operations proc_SSID_ops = {
};
static const struct file_operations proc_BSSList_ops = {
+ .owner = THIS_MODULE,
.read = proc_read,
.write = proc_write,
.open = proc_BSSList_open,
@@ -4379,6 +4384,7 @@ static const struct file_operations proc_BSSList_ops = {
};
static const struct file_operations proc_APList_ops = {
+ .owner = THIS_MODULE,
.read = proc_read,
.write = proc_write,
.open = proc_APList_open,
@@ -4386,6 +4392,7 @@ static const struct file_operations proc_APList_ops = {
};
static const struct file_operations proc_config_ops = {
+ .owner = THIS_MODULE,
.read = proc_read,
.write = proc_write,
.open = proc_config_open,
@@ -4393,6 +4400,7 @@ static const struct file_operations proc_config_ops = {
};
static const struct file_operations proc_wepkey_ops = {
+ .owner = THIS_MODULE,
.read = proc_read,
.write = proc_write,
.open = proc_wepkey_open,
@@ -4411,10 +4419,6 @@ struct proc_data {
void (*on_close) (struct inode *, struct file *);
};
-#ifndef SETPROC_OPS
-#define SETPROC_OPS(entry, ops) (entry)->proc_fops = &(ops)
-#endif
-
static int setup_proc_entry( struct net_device *dev,
struct airo_info *apriv ) {
struct proc_dir_entry *entry;
@@ -4430,100 +4434,76 @@ static int setup_proc_entry( struct net_device *dev,
apriv->proc_entry->owner = THIS_MODULE;
/* Setup the StatsDelta */
- entry = create_proc_entry("StatsDelta",
- S_IFREG | (S_IRUGO&proc_perm),
- apriv->proc_entry);
+ entry = proc_create_data("StatsDelta",
+ S_IFREG | (S_IRUGO&proc_perm),
+ apriv->proc_entry, &proc_statsdelta_ops, dev);
if (!entry)
goto fail_stats_delta;
entry->uid = proc_uid;
entry->gid = proc_gid;
- entry->data = dev;
- entry->owner = THIS_MODULE;
- SETPROC_OPS(entry, proc_statsdelta_ops);
/* Setup the Stats */
- entry = create_proc_entry("Stats",
- S_IFREG | (S_IRUGO&proc_perm),
- apriv->proc_entry);
+ entry = proc_create_data("Stats",
+ S_IFREG | (S_IRUGO&proc_perm),
+ apriv->proc_entry, &proc_stats_ops, dev);
if (!entry)
goto fail_stats;
entry->uid = proc_uid;
entry->gid = proc_gid;
- entry->data = dev;
- entry->owner = THIS_MODULE;
- SETPROC_OPS(entry, proc_stats_ops);
/* Setup the Status */
- entry = create_proc_entry("Status",
- S_IFREG | (S_IRUGO&proc_perm),
- apriv->proc_entry);
+ entry = proc_create_data("Status",
+ S_IFREG | (S_IRUGO&proc_perm),
+ apriv->proc_entry, &proc_status_ops, dev);
if (!entry)
goto fail_status;
entry->uid = proc_uid;
entry->gid = proc_gid;
- entry->data = dev;
- entry->owner = THIS_MODULE;
- SETPROC_OPS(entry, proc_status_ops);
/* Setup the Config */
- entry = create_proc_entry("Config",
- S_IFREG | proc_perm,
- apriv->proc_entry);
+ entry = proc_create_data("Config",
+ S_IFREG | proc_perm,
+ apriv->proc_entry, &proc_config_ops, dev);
if (!entry)
goto fail_config;
entry->uid = proc_uid;
entry->gid = proc_gid;
- entry->data = dev;
- entry->owner = THIS_MODULE;
- SETPROC_OPS(entry, proc_config_ops);
/* Setup the SSID */
- entry = create_proc_entry("SSID",
- S_IFREG | proc_perm,
- apriv->proc_entry);
+ entry = proc_create_data("SSID",
+ S_IFREG | proc_perm,
+ apriv->proc_entry, &proc_SSID_ops, dev);
if (!entry)
goto fail_ssid;
entry->uid = proc_uid;
entry->gid = proc_gid;
- entry->data = dev;
- entry->owner = THIS_MODULE;
- SETPROC_OPS(entry, proc_SSID_ops);
/* Setup the APList */
- entry = create_proc_entry("APList",
- S_IFREG | proc_perm,
- apriv->proc_entry);
+ entry = proc_create_data("APList",
+ S_IFREG | proc_perm,
+ apriv->proc_entry, &proc_APList_ops, dev);
if (!entry)
goto fail_aplist;
entry->uid = proc_uid;
entry->gid = proc_gid;
- entry->data = dev;
- entry->owner = THIS_MODULE;
- SETPROC_OPS(entry, proc_APList_ops);
/* Setup the BSSList */
- entry = create_proc_entry("BSSList",
- S_IFREG | proc_perm,
- apriv->proc_entry);
+ entry = proc_create_data("BSSList",
+ S_IFREG | proc_perm,
+ apriv->proc_entry, &proc_BSSList_ops, dev);
if (!entry)
goto fail_bsslist;
entry->uid = proc_uid;
entry->gid = proc_gid;
- entry->data = dev;
- entry->owner = THIS_MODULE;
- SETPROC_OPS(entry, proc_BSSList_ops);
/* Setup the WepKey */
- entry = create_proc_entry("WepKey",
- S_IFREG | proc_perm,
- apriv->proc_entry);
+ entry = proc_create_data("WepKey",
+ S_IFREG | proc_perm,
+ apriv->proc_entry, &proc_wepkey_ops, dev);
if (!entry)
goto fail_wepkey;
entry->uid = proc_uid;
entry->gid = proc_gid;
- entry->data = dev;
- entry->owner = THIS_MODULE;
- SETPROC_OPS(entry, proc_wepkey_ops);
return 0;
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 25/29] isdn: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (23 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 24/29] net: " Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-30 17:57 ` [patch, -git] isdn: hysdn_procconf.c build fix Ingo Molnar
2008-04-08 11:19 ` [PATCH 26/29] kernel: use non-racy method for proc entries creation Denis V. Lunev
` (3 subsequent siblings)
28 siblings, 1 reply; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
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: Karsten Keil <kkeil@suse.de>
CC: isdn4linux@listserv.isdn4linux.de
---
drivers/isdn/capi/kcapi_proc.c | 24 ++++++++++--------------
drivers/isdn/divert/divert_procfs.c | 5 ++---
drivers/isdn/hardware/eicon/divasproc.c | 8 ++------
drivers/isdn/hysdn/hysdn_procconf.c | 9 ++++-----
drivers/isdn/hysdn/hysdn_proclog.c | 8 ++++----
5 files changed, 22 insertions(+), 32 deletions(-)
diff --git a/drivers/isdn/capi/kcapi_proc.c b/drivers/isdn/capi/kcapi_proc.c
index 845a797..c29208b 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)
}
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
diff --git a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c
index 4fd4c46..8b256a6 100644
--- a/drivers/isdn/divert/divert_procfs.c
+++ b/drivers/isdn/divert/divert_procfs.c
@@ -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);
diff --git a/drivers/isdn/hardware/eicon/divasproc.c b/drivers/isdn/hardware/eicon/divasproc.c
index 0632a26..fae8958 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 = {
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);
}
diff --git a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c
index 27d890b..877be99 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)
/******************************************************/
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 */
diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c
index 27b3991..8991d2c 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)
/**************************************************/
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));
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 26/29] kernel: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (24 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 25/29] isdn: " Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 27/29] parisc: " Denis V. Lunev
` (2 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create()/proc_create_data() to make sure that ->proc_fops and
->data be setup before gluing PDE to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
kernel/configs.c | 4 ++--
kernel/dma.c | 7 +------
kernel/kallsyms.c | 6 +-----
kernel/latencytop.c | 9 +--------
kernel/lockdep_proc.c | 16 ++++------------
kernel/profile.c | 4 ++--
kernel/resource.c | 10 ++--------
kernel/sched_debug.c | 5 +----
kernel/time/timer_list.c | 5 +----
kernel/time/timer_stats.c | 5 +----
10 files changed, 16 insertions(+), 55 deletions(-)
diff --git a/kernel/configs.c b/kernel/configs.c
index d3a4b82..4c34521 100644
--- a/kernel/configs.c
+++ b/kernel/configs.c
@@ -79,11 +79,11 @@ static int __init ikconfig_init(void)
struct proc_dir_entry *entry;
/* create the current config file */
- entry = create_proc_entry("config.gz", S_IFREG | S_IRUGO, NULL);
+ entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
+ &ikconfig_file_ops);
if (!entry)
return -ENOMEM;
- entry->proc_fops = &ikconfig_file_ops;
entry->size = kernel_config_data_size;
return 0;
diff --git a/kernel/dma.c b/kernel/dma.c
index 6a82bb7..d2c60a8 100644
--- a/kernel/dma.c
+++ b/kernel/dma.c
@@ -149,12 +149,7 @@ static const struct file_operations proc_dma_operations = {
static int __init proc_dma_init(void)
{
- struct proc_dir_entry *e;
-
- e = create_proc_entry("dma", 0, NULL);
- if (e)
- e->proc_fops = &proc_dma_operations;
-
+ proc_create("dma", 0, NULL, &proc_dma_operations);
return 0;
}
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index f091d13..6fc0040 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -472,11 +472,7 @@ static const struct file_operations kallsyms_operations = {
static int __init kallsyms_init(void)
{
- struct proc_dir_entry *entry;
-
- entry = create_proc_entry("kallsyms", 0444, NULL);
- if (entry)
- entry->proc_fops = &kallsyms_operations;
+ proc_create("kallsyms", 0444, NULL, &kallsyms_operations);
return 0;
}
__initcall(kallsyms_init);
diff --git a/kernel/latencytop.c b/kernel/latencytop.c
index 7c74dab..5e7b45c 100644
--- a/kernel/latencytop.c
+++ b/kernel/latencytop.c
@@ -233,14 +233,7 @@ static struct file_operations lstats_fops = {
static int __init init_lstats_procfs(void)
{
- struct proc_dir_entry *pe;
-
- pe = create_proc_entry("latency_stats", 0644, NULL);
- if (!pe)
- return -ENOMEM;
-
- pe->proc_fops = &lstats_fops;
-
+ proc_create("latency_stats", 0644, NULL, &lstats_fops);
return 0;
}
__initcall(init_lstats_procfs);
diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
index 8a135bd..dc5d296 100644
--- a/kernel/lockdep_proc.c
+++ b/kernel/lockdep_proc.c
@@ -660,20 +660,12 @@ static const struct file_operations proc_lock_stat_operations = {
static int __init lockdep_proc_init(void)
{
- struct proc_dir_entry *entry;
-
- entry = create_proc_entry("lockdep", S_IRUSR, NULL);
- if (entry)
- entry->proc_fops = &proc_lockdep_operations;
-
- entry = create_proc_entry("lockdep_stats", S_IRUSR, NULL);
- if (entry)
- entry->proc_fops = &proc_lockdep_stats_operations;
+ proc_create("lockdep", S_IRUSR, NULL, &proc_lockdep_operations);
+ proc_create("lockdep_stats", S_IRUSR, NULL,
+ &proc_lockdep_stats_operations);
#ifdef CONFIG_LOCK_STAT
- entry = create_proc_entry("lock_stat", S_IRUSR, NULL);
- if (entry)
- entry->proc_fops = &proc_lock_stat_operations;
+ proc_create("lock_stat", S_IRUSR, NULL, &proc_lock_stat_operations);
#endif
return 0;
diff --git a/kernel/profile.c b/kernel/profile.c
index 3b7a1b0..1a21762 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -588,10 +588,10 @@ static int __init create_proc_profile(void)
return 0;
if (create_hash_tables())
return -1;
- entry = create_proc_entry("profile", S_IWUSR | S_IRUGO, NULL);
+ entry = proc_create("profile", S_IWUSR | S_IRUGO,
+ NULL, &proc_profile_operations);
if (!entry)
return 0;
- entry->proc_fops = &proc_profile_operations;
entry->size = (1+prof_len) * sizeof(atomic_t);
hotcpu_notifier(profile_cpu_callback, 0);
return 0;
diff --git a/kernel/resource.c b/kernel/resource.c
index 46ad4f4..da8ee1b 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -131,14 +131,8 @@ static const struct file_operations proc_iomem_operations = {
static int __init ioresources_init(void)
{
- struct proc_dir_entry *entry;
-
- entry = create_proc_entry("ioports", 0, NULL);
- if (entry)
- entry->proc_fops = &proc_ioports_operations;
- entry = create_proc_entry("iomem", 0, NULL);
- if (entry)
- entry->proc_fops = &proc_iomem_operations;
+ proc_create("ioports", 0, NULL, &proc_ioports_operations);
+ proc_create("iomem", 0, NULL, &proc_iomem_operations);
return 0;
}
__initcall(ioresources_init);
diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c
index 475b5ad..08dddd7 100644
--- a/kernel/sched_debug.c
+++ b/kernel/sched_debug.c
@@ -248,12 +248,9 @@ static int __init init_sched_debug_procfs(void)
{
struct proc_dir_entry *pe;
- pe = create_proc_entry("sched_debug", 0644, NULL);
+ pe = proc_create("sched_debug", 0644, NULL, &sched_debug_fops);
if (!pe)
return -ENOMEM;
-
- pe->proc_fops = &sched_debug_fops;
-
return 0;
}
diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
index 67fe8fc..a40e20f 100644
--- a/kernel/time/timer_list.c
+++ b/kernel/time/timer_list.c
@@ -278,12 +278,9 @@ static int __init init_timer_list_procfs(void)
{
struct proc_dir_entry *pe;
- pe = create_proc_entry("timer_list", 0644, NULL);
+ pe = proc_create("timer_list", 0644, NULL, &timer_list_fops);
if (!pe)
return -ENOMEM;
-
- pe->proc_fops = &timer_list_fops;
-
return 0;
}
__initcall(init_timer_list_procfs);
diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
index 417da8c..c994530 100644
--- a/kernel/time/timer_stats.c
+++ b/kernel/time/timer_stats.c
@@ -415,12 +415,9 @@ static int __init init_tstats_procfs(void)
{
struct proc_dir_entry *pe;
- pe = create_proc_entry("timer_stats", 0644, NULL);
+ pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
if (!pe)
return -ENOMEM;
-
- pe->proc_fops = &tstats_fops;
-
return 0;
}
__initcall(init_tstats_procfs);
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 27/29] parisc: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (25 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 26/29] kernel: use non-racy method for proc entries creation Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 28/29] drivers: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 29/29] " Denis V. Lunev
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create() to make sure that ->proc_fops be setup before gluing PDE
to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Kyle McMartin <kyle@parisc-linux.org>
CC: Matthew Wilcox <matthew@wil.cx>
CC: Grant Grundler <grundler@parisc-linux.org>
CC: linux-parisc@vger.kernel.org
---
drivers/parisc/ccio-dma.c | 14 +++++---------
drivers/parisc/sba_iommu.c | 14 +++++---------
2 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index 3482b83..f2b2549 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -1551,8 +1551,7 @@ static int __init ccio_probe(struct parisc_device *dev)
{
int i;
struct ioc *ioc, **ioc_p = &ioc_list;
- struct proc_dir_entry *info_entry, *bitmap_entry;
-
+
ioc = kzalloc(sizeof(struct ioc), GFP_KERNEL);
if (ioc == NULL) {
printk(KERN_ERR MODULE_NAME ": memory allocation failure\n");
@@ -1580,13 +1579,10 @@ static int __init ccio_probe(struct parisc_device *dev)
HBA_DATA(dev->dev.platform_data)->iommu = ioc;
if (ioc_count == 0) {
- info_entry = create_proc_entry(MODULE_NAME, 0, proc_runway_root);
- if (info_entry)
- info_entry->proc_fops = &ccio_proc_info_fops;
-
- bitmap_entry = create_proc_entry(MODULE_NAME"-bitmap", 0, proc_runway_root);
- if (bitmap_entry)
- bitmap_entry->proc_fops = &ccio_proc_bitmap_fops;
+ proc_create(MODULE_NAME, 0, proc_runway_root,
+ &ccio_proc_info_fops);
+ proc_create(MODULE_NAME"-bitmap", 0, proc_runway_root,
+ &ccio_proc_bitmap_fops);
}
ioc_count++;
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index 3890fe1..bc73b96 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -1895,7 +1895,9 @@ sba_driver_callback(struct parisc_device *dev)
int i;
char *version;
void __iomem *sba_addr = ioremap_nocache(dev->hpa.start, SBA_FUNC_SIZE);
- struct proc_dir_entry *info_entry, *bitmap_entry, *root;
+#ifdef CONFIG_PROC_FS
+ struct proc_dir_entry *root;
+#endif
sba_dump_ranges(sba_addr);
@@ -1973,14 +1975,8 @@ sba_driver_callback(struct parisc_device *dev)
break;
}
- info_entry = create_proc_entry("sba_iommu", 0, root);
- bitmap_entry = create_proc_entry("sba_iommu-bitmap", 0, root);
-
- if (info_entry)
- info_entry->proc_fops = &sba_proc_fops;
-
- if (bitmap_entry)
- bitmap_entry->proc_fops = &sba_proc_bitmap_fops;
+ proc_create("sba_iommu", 0, root, &sba_proc_fops);
+ proc_create("sba_iommu-bitmap", 0, root, &sba_proc_bitmap_fops);
#endif
parisc_vmerge_boundary = IOVP_SIZE;
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 28/29] drivers: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (26 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 27/29] parisc: " Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-08 11:19 ` [PATCH 29/29] " Denis V. Lunev
28 siblings, 0 replies; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create()/proc_create_data() to make sure that ->proc_fops and
->data be setup before gluing PDE to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/char/i8k.c | 6 ++----
drivers/char/misc.c | 27 +++++++++++++++------------
drivers/char/rtc.c | 6 ++----
drivers/char/toshiba.c | 3 +--
drivers/char/viotape.c | 9 +++------
5 files changed, 23 insertions(+), 28 deletions(-)
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c
index 8609b82..f49037b 100644
--- a/drivers/char/i8k.c
+++ b/drivers/char/i8k.c
@@ -82,6 +82,7 @@ static int i8k_ioctl(struct inode *, struct file *, unsigned int,
unsigned long);
static const struct file_operations i8k_fops = {
+ .owner = THIS_MODULE,
.open = i8k_open_fs,
.read = seq_read,
.llseek = seq_lseek,
@@ -554,13 +555,10 @@ static int __init i8k_init(void)
return -ENODEV;
/* Register the proc entry */
- proc_i8k = create_proc_entry("i8k", 0, NULL);
+ proc_i8k = proc_create("i8k", 0, NULL, &i8k_fops);
if (!proc_i8k)
return -ENOENT;
- proc_i8k->proc_fops = &i8k_fops;
- proc_i8k->owner = THIS_MODULE;
-
printk(KERN_INFO
"Dell laptop SMM driver v%s Massimo Dal Zotto (dz@debian.org)\n",
I8K_VERSION);
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index bc717e4..2f8ceb0 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -262,23 +262,26 @@ EXPORT_SYMBOL(misc_deregister);
static int __init misc_init(void)
{
-#ifdef CONFIG_PROC_FS
- struct proc_dir_entry *ent;
+ int err;
- ent = create_proc_entry("misc", 0, NULL);
- if (ent)
- ent->proc_fops = &misc_proc_fops;
+#ifdef CONFIG_PROC_FS
+ proc_create("misc", 0, NULL, &misc_proc_fops);
#endif
misc_class = class_create(THIS_MODULE, "misc");
+ err = PTR_ERR(misc_class);
if (IS_ERR(misc_class))
- return PTR_ERR(misc_class);
+ goto fail_remove;
- if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) {
- printk("unable to get major %d for misc devices\n",
- MISC_MAJOR);
- class_destroy(misc_class);
- return -EIO;
- }
+ err = -EIO;
+ if (register_chrdev(MISC_MAJOR,"misc",&misc_fops))
+ goto fail_printk;
return 0;
+
+fail_printk:
+ printk("unable to get major %d for misc devices\n", MISC_MAJOR);
+ class_destroy(misc_class);
+fail_remove:
+ remove_proc_entry("misc", NULL);
+ return err;
}
subsys_initcall(misc_init);
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index 5c3142b..b775df9 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -1068,10 +1068,8 @@ no_irq:
}
#ifdef CONFIG_PROC_FS
- ent = create_proc_entry("driver/rtc", 0, NULL);
- if (ent)
- ent->proc_fops = &rtc_proc_fops;
- else
+ ent = proc_create("driver/rtc", 0, NULL, &rtc_proc_fops);
+ if (!ent)
printk(KERN_WARNING "rtc: Failed to register with procfs.\n");
#endif
diff --git a/drivers/char/toshiba.c b/drivers/char/toshiba.c
index ce5ebe3..64f1cee 100644
--- a/drivers/char/toshiba.c
+++ b/drivers/char/toshiba.c
@@ -520,12 +520,11 @@ static int __init toshiba_init(void)
{
struct proc_dir_entry *pde;
- pde = create_proc_entry("toshiba", 0, NULL);
+ pde = proc_create("toshiba", 0, NULL, &proc_toshiba_fops);
if (!pde) {
misc_deregister(&tosh_device);
return -ENOMEM;
}
- pde->proc_fops = &proc_toshiba_fops;
}
#endif
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c
index db7a731..58aad63 100644
--- a/drivers/char/viotape.c
+++ b/drivers/char/viotape.c
@@ -249,6 +249,7 @@ static int proc_viotape_open(struct inode *inode, struct file *file)
}
static const struct file_operations proc_viotape_operations = {
+ .owner = THIS_MODULE,
.open = proc_viotape_open,
.read = seq_read,
.llseek = seq_lseek,
@@ -915,7 +916,6 @@ static struct vio_driver viotape_driver = {
int __init viotap_init(void)
{
int ret;
- struct proc_dir_entry *e;
if (!firmware_has_feature(FW_FEATURE_ISERIES))
return -ENODEV;
@@ -968,11 +968,8 @@ int __init viotap_init(void)
if (ret)
goto unreg_class;
- e = create_proc_entry("iSeries/viotape", S_IFREG|S_IRUGO, NULL);
- if (e) {
- e->owner = THIS_MODULE;
- e->proc_fops = &proc_viotape_operations;
- }
+ proc_create("iSeries/viotape", S_IFREG|S_IRUGO, NULL,
+ &proc_viotape_operations);
return 0;
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 29/29] drivers: use non-racy method for proc entries creation
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
` (27 preceding siblings ...)
2008-04-08 11:19 ` [PATCH 28/29] drivers: " Denis V. Lunev
@ 2008-04-08 11:19 ` Denis V. Lunev
2008-04-17 17:13 ` Dmitry Torokhov
28 siblings, 1 reply; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-08 11:19 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Denis V. Lunev
Use proc_create()/proc_create_data() to make sure that ->proc_fops and
->data be setup before gluing PDE to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/block/pktcdvd.c | 7 +------
drivers/cdrom/viocd.c | 10 +++-------
drivers/ide/ide-proc.c | 7 ++-----
drivers/input/input.c | 12 ++++--------
drivers/md/md.c | 6 +-----
drivers/media/video/zoran_procfs.c | 7 +++----
drivers/message/i2o/i2o_proc.c | 6 ++----
drivers/misc/hdpuftrs/hdpu_cpustate.c | 5 +----
drivers/misc/hdpuftrs/hdpu_nexus.c | 13 ++++---------
drivers/pci/proc.c | 13 ++++++-------
drivers/pnp/isapnp/proc.c | 7 +++----
drivers/rapidio/rio.c | 6 +-----
drivers/rtc/rtc-proc.c | 8 +++-----
13 files changed, 34 insertions(+), 73 deletions(-)
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 0431e59..fd04729 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -2744,7 +2744,6 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
int i;
int ret = 0;
char b[BDEVNAME_SIZE];
- struct proc_dir_entry *proc;
struct block_device *bdev;
if (pd->pkt_dev == dev) {
@@ -2788,11 +2787,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
goto out_mem;
}
- proc = create_proc_entry(pd->name, 0, pkt_proc);
- if (proc) {
- proc->data = pd;
- proc->proc_fops = &pkt_proc_fops;
- }
+ proc_create_data(pd->name, 0, pkt_proc, &pkt_proc_fops, pd);
DPRINTK(DRIVER_NAME": writer %s mapped to %s\n", pd->name, bdevname(bdev, b));
return 0;
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c
index b74b6c2..5245a4a 100644
--- a/drivers/cdrom/viocd.c
+++ b/drivers/cdrom/viocd.c
@@ -144,6 +144,7 @@ static int proc_viocd_open(struct inode *inode, struct file *file)
}
static const struct file_operations proc_viocd_operations = {
+ .owner = THIS_MODULE,
.open = proc_viocd_open,
.read = seq_read,
.llseek = seq_lseek,
@@ -679,7 +680,6 @@ static struct vio_driver viocd_driver = {
static int __init viocd_init(void)
{
- struct proc_dir_entry *e;
int ret = 0;
if (!firmware_has_feature(FW_FEATURE_ISERIES))
@@ -719,12 +719,8 @@ static int __init viocd_init(void)
if (ret)
goto out_free_info;
- e = create_proc_entry("iSeries/viocd", S_IFREG|S_IRUGO, NULL);
- if (e) {
- e->owner = THIS_MODULE;
- e->proc_fops = &proc_viocd_operations;
- }
-
+ proc_create("iSeries/viocd", S_IFREG|S_IRUGO, NULL,
+ &proc_viocd_operations);
return 0;
out_free_info:
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index d9d98ac..5db5da1 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -830,6 +830,7 @@ static int ide_drivers_open(struct inode *inode, struct file *file)
}
static const struct file_operations ide_drivers_operations = {
+ .owner = THIS_MODULE,
.open = ide_drivers_open,
.read = seq_read,
.llseek = seq_lseek,
@@ -838,16 +839,12 @@ static const struct file_operations ide_drivers_operations = {
void proc_ide_create(void)
{
- struct proc_dir_entry *entry;
-
proc_ide_root = proc_mkdir("ide", NULL);
if (!proc_ide_root)
return;
- entry = create_proc_entry("drivers", 0, proc_ide_root);
- if (entry)
- entry->proc_fops = &ide_drivers_operations;
+ proc_create("drivers", 0, proc_ide_root, &ide_drivers_operations);
}
void proc_ide_destroy(void)
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 1142660..27006fc 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -904,20 +904,16 @@ static int __init input_proc_init(void)
proc_bus_input_dir->owner = THIS_MODULE;
- entry = create_proc_entry("devices", 0, proc_bus_input_dir);
+ entry = proc_create("devices", 0, proc_bus_input_dir,
+ &input_devices_fileops);
if (!entry)
goto fail1;
- entry->owner = THIS_MODULE;
- entry->proc_fops = &input_devices_fileops;
-
- entry = create_proc_entry("handlers", 0, proc_bus_input_dir);
+ entry = proc_create("handlers", 0, proc_bus_input_dir,
+ &input_handlers_fileops);
if (!entry)
goto fail2;
- entry->owner = THIS_MODULE;
- entry->proc_fops = &input_handlers_fileops;
-
return 0;
fail2: remove_proc_entry("devices", proc_bus_input_dir);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 0f7ff94..1d4a396 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5947,13 +5947,9 @@ static struct notifier_block md_notifier = {
static void md_geninit(void)
{
- struct proc_dir_entry *p;
-
dprintk("md: sizeof(mdp_super_t) = %d\n", (int)sizeof(mdp_super_t));
- p = create_proc_entry("mdstat", S_IRUGO, NULL);
- if (p)
- p->proc_fops = &md_seq_fops;
+ proc_create("mdstat", S_IRUGO, NULL, &md_seq_fops);
}
static int __init md_init(void)
diff --git a/drivers/media/video/zoran_procfs.c b/drivers/media/video/zoran_procfs.c
index 328ed6e..870bc5a 100644
--- a/drivers/media/video/zoran_procfs.c
+++ b/drivers/media/video/zoran_procfs.c
@@ -180,6 +180,7 @@ static ssize_t zoran_write(struct file *file, const char __user *buffer,
}
static const struct file_operations zoran_operations = {
+ .owner = THIS_MODULE,
.open = zoran_open,
.read = seq_read,
.write = zoran_write,
@@ -195,10 +196,8 @@ zoran_proc_init (struct zoran *zr)
char name[8];
snprintf(name, 7, "zoran%d", zr->id);
- if ((zr->zoran_proc = create_proc_entry(name, 0, NULL))) {
- zr->zoran_proc->data = zr;
- zr->zoran_proc->owner = THIS_MODULE;
- zr->zoran_proc->proc_fops = &zoran_operations;
+ zr->zoran_proc = proc_create_data(name, 0, NULL, &zoran_operations, zr);
+ if (zr->zoran_proc != NULL) {
dprintk(2,
KERN_INFO
"%s: procfs entry /proc/%s allocated. data=%p\n",
diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
index 6fdd072..54a3016 100644
--- a/drivers/message/i2o/i2o_proc.c
+++ b/drivers/message/i2o/i2o_proc.c
@@ -1893,13 +1893,11 @@ static int i2o_proc_create_entries(struct proc_dir_entry *dir,
struct proc_dir_entry *tmp;
while (i2o_pe->name) {
- tmp = create_proc_entry(i2o_pe->name, i2o_pe->mode, dir);
+ tmp = proc_create_data(i2o_pe->name, i2o_pe->mode, dir,
+ i2o_pe->fops, data);
if (!tmp)
return -1;
- tmp->data = data;
- tmp->proc_fops = i2o_pe->fops;
-
i2o_pe++;
}
diff --git a/drivers/misc/hdpuftrs/hdpu_cpustate.c b/drivers/misc/hdpuftrs/hdpu_cpustate.c
index 4ff3512..8a3b222 100644
--- a/drivers/misc/hdpuftrs/hdpu_cpustate.c
+++ b/drivers/misc/hdpuftrs/hdpu_cpustate.c
@@ -209,13 +209,10 @@ static int hdpu_cpustate_probe(struct platform_device *pdev)
return ret;
}
- proc_de = create_proc_entry("sky_cpustate", 0666, NULL);
+ proc_de = proc_create("sky_cpustate", 0666, NULL, &proc_cpustate);
if (!proc_de) {
printk(KERN_WARNING "sky_cpustate: "
"Unable to create proc entry\n");
- } else {
- proc_de->proc_fops = &proc_cpustate;
- proc_de->owner = THIS_MODULE;
}
printk(KERN_INFO "Sky CPU State Driver v" SKY_CPUSTATE_VERSION "\n");
diff --git a/drivers/misc/hdpuftrs/hdpu_nexus.c b/drivers/misc/hdpuftrs/hdpu_nexus.c
index 4137022..40f1b20 100644
--- a/drivers/misc/hdpuftrs/hdpu_nexus.c
+++ b/drivers/misc/hdpuftrs/hdpu_nexus.c
@@ -101,22 +101,17 @@ static int hdpu_nexus_probe(struct platform_device *pdev)
printk(KERN_ERR "sky_nexus: Could not map slot id\n");
}
- hdpu_slot_id = create_proc_entry("sky_slot_id", 0666, NULL);
- if (!hdpu_slot_id)
+ hdpu_slot_id = proc_create("sky_slot_id", 0666, NULL, &proc_slot_id);
+ if (!hdpu_slot_id) {
printk(KERN_WARNING "sky_nexus: "
"Unable to create proc dir entry: sky_slot_id\n");
- } else {
- hdpu_slot_id->proc_fops = &proc_slot_id;
- hdpu_slot_id->owner = THIS_MODULE;
}
- hdpu_chassis_id = create_proc_entry("sky_chassis_id", 0666, NULL);
+ hdpu_chassis_id = proc_create("sky_chassis_id", 0666, NULL,
+ &proc_chassis_id);
if (!hdpu_chassis_id)
printk(KERN_WARNING "sky_nexus: "
"Unable to create proc dir entry: sky_chassis_id\n");
- } else {
- hdpu_chassis_id->proc_fops = &proc_chassis_id;
- hdpu_chassis_id->owner = THIS_MODULE;
}
return 0;
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 7b5e45b..963a976 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -293,6 +293,7 @@ static int proc_bus_pci_release(struct inode *inode, struct file *file)
#endif /* HAVE_PCI_MMAP */
static const struct file_operations proc_bus_pci_operations = {
+ .owner = THIS_MODULE,
.llseek = proc_bus_pci_lseek,
.read = proc_bus_pci_read,
.write = proc_bus_pci_write,
@@ -406,11 +407,10 @@ int pci_proc_attach_device(struct pci_dev *dev)
}
sprintf(name, "%02x.%x", PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
- e = create_proc_entry(name, S_IFREG | S_IRUGO | S_IWUSR, bus->procdir);
+ e = proc_create_data(name, S_IFREG | S_IRUGO | S_IWUSR, bus->procdir,
+ &proc_bus_pci_operations, dev);
if (!e)
return -ENOMEM;
- e->proc_fops = &proc_bus_pci_operations;
- e->data = dev;
e->size = dev->cfg_size;
dev->procent = e;
@@ -462,6 +462,7 @@ static int proc_bus_pci_dev_open(struct inode *inode, struct file *file)
return seq_open(file, &proc_bus_pci_devices_op);
}
static const struct file_operations proc_bus_pci_dev_operations = {
+ .owner = THIS_MODULE,
.open = proc_bus_pci_dev_open,
.read = seq_read,
.llseek = seq_lseek,
@@ -470,12 +471,10 @@ static const struct file_operations proc_bus_pci_dev_operations = {
static int __init pci_proc_init(void)
{
- struct proc_dir_entry *entry;
struct pci_dev *dev = NULL;
proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
- entry = create_proc_entry("devices", 0, proc_bus_pci_dir);
- if (entry)
- entry->proc_fops = &proc_bus_pci_dev_operations;
+ proc_create("devices", 0, proc_bus_pci_dir,
+ &proc_bus_pci_dev_operations);
proc_initialized = 1;
while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
pci_proc_attach_device(dev);
diff --git a/drivers/pnp/isapnp/proc.c b/drivers/pnp/isapnp/proc.c
index e1d1f2a..3f94eda 100644
--- a/drivers/pnp/isapnp/proc.c
+++ b/drivers/pnp/isapnp/proc.c
@@ -85,6 +85,7 @@ static ssize_t isapnp_proc_bus_read(struct file *file, char __user * buf,
}
static const struct file_operations isapnp_proc_bus_file_operations = {
+ .owner = THIS_MODULE,
.llseek = isapnp_proc_bus_lseek,
.read = isapnp_proc_bus_read,
};
@@ -102,12 +103,10 @@ static int isapnp_proc_attach_device(struct pnp_dev *dev)
return -ENOMEM;
}
sprintf(name, "%02x", dev->number);
- e = dev->procent = create_proc_entry(name, S_IFREG | S_IRUGO, de);
+ e = dev->procent = proc_create_data(name, S_IFREG | S_IRUGO, de,
+ &isapnp_proc_bus_file_operations, dev);
if (!e)
return -ENOMEM;
- e->proc_fops = &isapnp_proc_bus_file_operations;
- e->owner = THIS_MODULE;
- e->data = dev;
e->size = 256;
return 0;
}
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c
index 9bae341..e048ef6 100644
--- a/drivers/rapidio/rio.c
+++ b/drivers/rapidio/rio.c
@@ -984,11 +984,7 @@ static const struct file_operations proc_riores_operations = {
static int __init rioresources_init(void)
{
- struct proc_dir_entry *entry;
-
- entry = create_proc_entry("riores", 0, NULL);
- if (entry)
- entry->proc_fops = &proc_riores_operations;
+ proc_create("riores", 0, NULL, &proc_riores_operations);
return 0;
}
__initcall(rioresources_init);
diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c
index 8d300e6..0c6257a 100644
--- a/drivers/rtc/rtc-proc.c
+++ b/drivers/rtc/rtc-proc.c
@@ -108,12 +108,10 @@ void rtc_proc_add_device(struct rtc_device *rtc)
if (rtc->id == 0) {
struct proc_dir_entry *ent;
- ent = create_proc_entry("driver/rtc", 0, NULL);
- if (ent) {
- ent->proc_fops = &rtc_proc_fops;
+ ent = proc_create_data("driver/rtc", 0, NULL,
+ &rtc_proc_fops, rtc);
+ if (ent)
ent->owner = rtc->owner;
- ent->data = rtc;
- }
}
}
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH 29/29] drivers: use non-racy method for proc entries creation
2008-04-08 11:19 ` [PATCH 29/29] " Denis V. Lunev
@ 2008-04-17 17:13 ` Dmitry Torokhov
0 siblings, 0 replies; 39+ messages in thread
From: Dmitry Torokhov @ 2008-04-17 17:13 UTC (permalink / raw)
To: Denis V. Lunev; +Cc: akpm, linux-kernel
On Tue, Apr 08, 2008 at 03:19:36PM +0400, Denis V. Lunev wrote:
> Use proc_create()/proc_create_data() to make sure that ->proc_fops and
> ->data be setup before gluing PDE to main tree.
>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Greg Kroah-Hartman <gregkh@suse.de>
No objections to the input change.
Acked-by: Dmitry Torokhov <dtor@mail.ru>
--
Dmitry
^ permalink raw reply [flat|nested] 39+ messages in thread
* [patch, -git] isdn: hysdn_procconf.c build fix
2008-04-08 11:19 ` [PATCH 25/29] isdn: " Denis V. Lunev
@ 2008-04-30 17:57 ` Ingo Molnar
2008-04-30 18:10 ` Andrew Morton
0 siblings, 1 reply; 39+ messages in thread
From: Ingo Molnar @ 2008-04-30 17:57 UTC (permalink / raw)
To: Denis V. Lunev; +Cc: akpm, linux-kernel
x86.git randconfig testing found the following build error in latest
-git:
CC [M] drivers/isdn/hysdn/hysdn_procconf.o
CC [M] drivers/isdn/hysdn/hysdn_init.o
drivers/isdn/hysdn/hysdn_procconf.c: In function 'hysdn_procconf_init':
drivers/isdn/hysdn/hysdn_procconf.c:408: error: too few arguments to function 'proc_create'
with the following config:
http://redhat.com/~mingo/misc/config-Wed_Apr_30_15_12_48_CEST_2008.bad
Ob'grumpy: this file was not even build-tested by any of the parties who
turned it into upstream commit ac41cfd19b ("isdn: use non-racy method
for proc entries creation").
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
drivers/isdn/hysdn/hysdn_procconf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Index: linux/drivers/isdn/hysdn/hysdn_procconf.c
===================================================================
--- linux.orig/drivers/isdn/hysdn/hysdn_procconf.c
+++ linux/drivers/isdn/hysdn/hysdn_procconf.c
@@ -405,7 +405,8 @@ hysdn_procconf_init(void)
sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid);
if ((card->procconf = (void *) proc_create(conf_name,
S_IFREG | S_IRUGO | S_IWUSR,
- hysdn_proc_entry)) != NULL) {
+ hysdn_proc_entry,
+ &conf_fops)) != NULL) {
hysdn_proclog_init(card); /* init the log file entry */
}
card = card->next; /* next entry */
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [patch, -git] isdn: hysdn_procconf.c build fix
2008-04-30 17:57 ` [patch, -git] isdn: hysdn_procconf.c build fix Ingo Molnar
@ 2008-04-30 18:10 ` Andrew Morton
2008-04-30 18:30 ` Ingo Molnar
0 siblings, 1 reply; 39+ messages in thread
From: Andrew Morton @ 2008-04-30 18:10 UTC (permalink / raw)
To: Ingo Molnar; +Cc: den, linux-kernel
On Wed, 30 Apr 2008 19:57:40 +0200
Ingo Molnar <mingo@elte.hu> wrote:
> Ob'grumpy: this file was not even build-tested by any of the parties who
> turned it into upstream commit ac41cfd19b ("isdn: use non-racy method
> for proc entries creation").
That's because this stupidity:
config HYSDN
tristate "Hypercope HYSDN cards (Champ, Ergo, Metro) support (module only)"
depends on m && PROC_FS && PCI && BROKEN_ON_SMP
breaks allmodconfig coverage testing.
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [patch, -git] isdn: hysdn_procconf.c build fix
2008-04-30 18:10 ` Andrew Morton
@ 2008-04-30 18:30 ` Ingo Molnar
2008-04-30 18:47 ` Andrew Morton
0 siblings, 1 reply; 39+ messages in thread
From: Ingo Molnar @ 2008-04-30 18:30 UTC (permalink / raw)
To: Andrew Morton; +Cc: den, linux-kernel
* Andrew Morton <akpm@linux-foundation.org> wrote:
> On Wed, 30 Apr 2008 19:57:40 +0200
> Ingo Molnar <mingo@elte.hu> wrote:
>
> > Ob'grumpy: this file was not even build-tested by any of the parties
> > who turned it into upstream commit ac41cfd19b ("isdn: use non-racy
> > method for proc entries creation").
>
> That's because this stupidity:
>
> config HYSDN
> tristate "Hypercope HYSDN cards (Champ, Ergo, Metro) support (module only)"
> depends on m && PROC_FS && PCI && BROKEN_ON_SMP
>
> breaks allmodconfig coverage testing.
yeah. There's a trick though that we use in the x86 tree (and which i'm
using in a script when queuing up new patches). The following command
will punch through any Kconfig black holes:
make drivers/isdn/hysdn/hysdn_procconf.o
(it wont always work as it needs a halfways reasonable .config, but it
works well enough to be part of my workflow.)
note that there's tons more stuff and dependencies that plain
allmodconfig does not catch - in this merge window alone i'm at around
20 fixes so far.
Ingo
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [patch, -git] isdn: hysdn_procconf.c build fix
2008-04-30 18:30 ` Ingo Molnar
@ 2008-04-30 18:47 ` Andrew Morton
2008-04-30 19:03 ` Denis V. Lunev
0 siblings, 1 reply; 39+ messages in thread
From: Andrew Morton @ 2008-04-30 18:47 UTC (permalink / raw)
To: Ingo Molnar; +Cc: den, linux-kernel
On Wed, 30 Apr 2008 20:30:51 +0200
Ingo Molnar <mingo@elte.hu> wrote:
>
> * Andrew Morton <akpm@linux-foundation.org> wrote:
>
> > On Wed, 30 Apr 2008 19:57:40 +0200
> > Ingo Molnar <mingo@elte.hu> wrote:
> >
> > > Ob'grumpy: this file was not even build-tested by any of the parties
> > > who turned it into upstream commit ac41cfd19b ("isdn: use non-racy
> > > method for proc entries creation").
> >
> > That's because this stupidity:
> >
> > config HYSDN
> > tristate "Hypercope HYSDN cards (Champ, Ergo, Metro) support (module only)"
> > depends on m && PROC_FS && PCI && BROKEN_ON_SMP
> >
> > breaks allmodconfig coverage testing.
>
> yeah. There's a trick though that we use in the x86 tree (and which i'm
> using in a script when queuing up new patches). The following command
> will punch through any Kconfig black holes:
>
> make drivers/isdn/hysdn/hysdn_procconf.o
That's daft, sorry. We shouldn't expect everyone to do stuff like that.
> (it wont always work as it needs a halfways reasonable .config, but it
> works well enough to be part of my workflow.)
>
> note that there's tons more stuff and dependencies that plain
> allmodconfig does not catch - in this merge window alone i'm at around
> 20 fixes so far.
allmodconfig is for one thing and one thing only: compilation coverage
testing. If there is anything which is not compiled after `make
allmodconfig' then that's a bug.
But how to fix it? Perhaps we need to add a CONFIG_ALLFOOCONFIG which can
be tested at the appropriate places.
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [patch, -git] isdn: hysdn_procconf.c build fix
2008-04-30 18:47 ` Andrew Morton
@ 2008-04-30 19:03 ` Denis V. Lunev
2008-04-30 19:14 ` Andrew Morton
0 siblings, 1 reply; 39+ messages in thread
From: Denis V. Lunev @ 2008-04-30 19:03 UTC (permalink / raw)
To: Andrew Morton; +Cc: Ingo Molnar, linux-kernel
On Wed, 2008-04-30 at 11:47 -0700, Andrew Morton wrote:
> On Wed, 30 Apr 2008 20:30:51 +0200
> Ingo Molnar <mingo@elte.hu> wrote:
>
> >
> > * Andrew Morton <akpm@linux-foundation.org> wrote:
> >
> > > On Wed, 30 Apr 2008 19:57:40 +0200
> > > Ingo Molnar <mingo@elte.hu> wrote:
> > >
> > > > Ob'grumpy: this file was not even build-tested by any of the parties
> > > > who turned it into upstream commit ac41cfd19b ("isdn: use non-racy
> > > > method for proc entries creation").
> > >
> > > That's because this stupidity:
> > >
> > > config HYSDN
> > > tristate "Hypercope HYSDN cards (Champ, Ergo, Metro) support (module only)"
> > > depends on m && PROC_FS && PCI && BROKEN_ON_SMP
> > >
> > > breaks allmodconfig coverage testing.
> >
> > yeah. There's a trick though that we use in the x86 tree (and which i'm
> > using in a script when queuing up new patches). The following command
> > will punch through any Kconfig black holes:
> >
> > make drivers/isdn/hysdn/hysdn_procconf.o
>
> That's daft, sorry. We shouldn't expect everyone to do stuff like that.
>
> > (it wont always work as it needs a halfways reasonable .config, but it
> > works well enough to be part of my workflow.)
> >
> > note that there's tons more stuff and dependencies that plain
> > allmodconfig does not catch - in this merge window alone i'm at around
> > 20 fixes so far.
>
> allmodconfig is for one thing and one thing only: compilation coverage
> testing. If there is anything which is not compiled after `make
> allmodconfig' then that's a bug.
>
> But how to fix it? Perhaps we need to add a CONFIG_ALLFOOCONFIG which can
> be tested at the appropriate places.
I think that the same should be applied to allyesconfig
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [patch, -git] isdn: hysdn_procconf.c build fix
2008-04-30 19:03 ` Denis V. Lunev
@ 2008-04-30 19:14 ` Andrew Morton
2008-04-30 19:24 ` Harvey Harrison
0 siblings, 1 reply; 39+ messages in thread
From: Andrew Morton @ 2008-04-30 19:14 UTC (permalink / raw)
To: Denis V. Lunev; +Cc: mingo, linux-kernel
On Wed, 30 Apr 2008 23:03:05 +0400
"Denis V. Lunev" <den@openvz.org> wrote:
> On Wed, 2008-04-30 at 11:47 -0700, Andrew Morton wrote:
> > On Wed, 30 Apr 2008 20:30:51 +0200
> > Ingo Molnar <mingo@elte.hu> wrote:
> >
> > >
> > > * Andrew Morton <akpm@linux-foundation.org> wrote:
> > >
> > > > On Wed, 30 Apr 2008 19:57:40 +0200
> > > > Ingo Molnar <mingo@elte.hu> wrote:
> > > >
> > > > > Ob'grumpy: this file was not even build-tested by any of the parties
> > > > > who turned it into upstream commit ac41cfd19b ("isdn: use non-racy
> > > > > method for proc entries creation").
> > > >
> > > > That's because this stupidity:
> > > >
> > > > config HYSDN
> > > > tristate "Hypercope HYSDN cards (Champ, Ergo, Metro) support (module only)"
> > > > depends on m && PROC_FS && PCI && BROKEN_ON_SMP
> > > >
> > > > breaks allmodconfig coverage testing.
> > >
> > > yeah. There's a trick though that we use in the x86 tree (and which i'm
> > > using in a script when queuing up new patches). The following command
> > > will punch through any Kconfig black holes:
> > >
> > > make drivers/isdn/hysdn/hysdn_procconf.o
> >
> > That's daft, sorry. We shouldn't expect everyone to do stuff like that.
> >
> > > (it wont always work as it needs a halfways reasonable .config, but it
> > > works well enough to be part of my workflow.)
> > >
> > > note that there's tons more stuff and dependencies that plain
> > > allmodconfig does not catch - in this merge window alone i'm at around
> > > 20 fixes so far.
> >
> > allmodconfig is for one thing and one thing only: compilation coverage
> > testing. If there is anything which is not compiled after `make
> > allmodconfig' then that's a bug.
> >
> > But how to fix it? Perhaps we need to add a CONFIG_ALLFOOCONFIG which can
> > be tested at the appropriate places.
>
> I think that the same should be applied to allyesconfig
That's what ALLFOOCONFIG refers to ;)
There _might_ be a need to discriminate between allyesconfig and
allmodconfig, but usually not, I expect.
Perhaps we should implement CONFIG_ALLYESCONFIG, CONFIG_ALLMODCONFIG and
CONFIG_ALLFOOCONFIG, where
ALLFOOCONFIG = ALLYESCONFIG || ALLMODCONFIG
(where FOO is renamed to something sensible, but what?)
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [patch, -git] isdn: hysdn_procconf.c build fix
2008-04-30 19:14 ` Andrew Morton
@ 2008-04-30 19:24 ` Harvey Harrison
2008-04-30 21:21 ` Alexey Dobriyan
0 siblings, 1 reply; 39+ messages in thread
From: Harvey Harrison @ 2008-04-30 19:24 UTC (permalink / raw)
To: Andrew Morton; +Cc: Denis V. Lunev, mingo, linux-kernel
On Wed, 2008-04-30 at 12:14 -0700, Andrew Morton wrote:
> On Wed, 30 Apr 2008 23:03:05 +0400
> "Denis V. Lunev" <den@openvz.org> wrote:
> > >
> > > allmodconfig is for one thing and one thing only: compilation coverage
> > > testing. If there is anything which is not compiled after `make
> > > allmodconfig' then that's a bug.
> > >
> > > But how to fix it? Perhaps we need to add a CONFIG_ALLFOOCONFIG which can
> > > be tested at the appropriate places.
> >
> > I think that the same should be applied to allyesconfig
>
> That's what ALLFOOCONFIG refers to ;)
>
> There _might_ be a need to discriminate between allyesconfig and
> allmodconfig, but usually not, I expect.
>
> Perhaps we should implement CONFIG_ALLYESCONFIG, CONFIG_ALLMODCONFIG and
> CONFIG_ALLFOOCONFIG, where
>
> ALLFOOCONFIG = ALLYESCONFIG || ALLMODCONFIG
>
> (where FOO is renamed to something sensible, but what?)
ALLBUILDCONFIG
Harvey
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [patch, -git] isdn: hysdn_procconf.c build fix
2008-04-30 19:24 ` Harvey Harrison
@ 2008-04-30 21:21 ` Alexey Dobriyan
0 siblings, 0 replies; 39+ messages in thread
From: Alexey Dobriyan @ 2008-04-30 21:21 UTC (permalink / raw)
To: Harvey Harrison; +Cc: Andrew Morton, Denis V. Lunev, mingo, linux-kernel
On Wed, Apr 30, 2008 at 12:24:47PM -0700, Harvey Harrison wrote:
> On Wed, 2008-04-30 at 12:14 -0700, Andrew Morton wrote:
> > On Wed, 30 Apr 2008 23:03:05 +0400
> > "Denis V. Lunev" <den@openvz.org> wrote:
> > > >
> > > > allmodconfig is for one thing and one thing only: compilation coverage
> > > > testing. If there is anything which is not compiled after `make
> > > > allmodconfig' then that's a bug.
> > > >
> > > > But how to fix it? Perhaps we need to add a CONFIG_ALLFOOCONFIG which can
> > > > be tested at the appropriate places.
> > >
> > > I think that the same should be applied to allyesconfig
> >
> > That's what ALLFOOCONFIG refers to ;)
> >
> > There _might_ be a need to discriminate between allyesconfig and
> > allmodconfig, but usually not, I expect.
> >
> > Perhaps we should implement CONFIG_ALLYESCONFIG, CONFIG_ALLMODCONFIG and
> > CONFIG_ALLFOOCONFIG, where
> >
> > ALLFOOCONFIG = ALLYESCONFIG || ALLMODCONFIG
> >
> > (where FOO is renamed to something sensible, but what?)
>
> ALLBUILDCONFIG
ALLCRAPCONFIG
Driver wasn't built because of BROKEN_ON_SMP, so both allyes and allmod
wouldn't help.
If one repeats Ingo's trick on e.g. driver that is arch specific from other
arch, compile will die horrible death due to different includes, so the
trick is not universal.
Things that help:
* UP allmodconfig builds
echo 'CONFIG_SMP=n' >1
make KCONFIG_ALLCONFIG=1 allmodconfig
alpha-smp-n-debug-n.log:
CC [M] drivers/isdn/hysdn/hysdn_procconf.o
drivers/isdn/hysdn/hysdn_procconf.c: In function 'hysdn_procconf_init':
drivers/isdn/hysdn/hysdn_procconf.c:408: error: too few arguments to function 'proc_create'
* double-checking logs that driver indeed was rebuilt
* attention, attention, attention -- code can hide in huge ifdef section
and config option won't be turned on, so driver compiles, but not
relevant part.
^ permalink raw reply [flat|nested] 39+ messages in thread
end of thread, other threads:[~2008-04-30 20:25 UTC | newest]
Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
2008-04-08 11:19 ` [PATCH 1/29] proc: introduce proc_create_data to setup de->data Denis V. Lunev
2008-04-08 11:19 ` [PATCH 2/29] nfsd: use proc_create to setup de->proc_fops Denis V. Lunev
2008-04-08 11:19 ` [PATCH 3/29] nfs: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 4/29] afs: use non-racy method for proc entries creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 5/29] ext4: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 6/29] reiserfs: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 7/29] jbd2: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 8/29] proc: use non-racy method for /proc/page_owner creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 9/29] sysvipc: use non-racy method for proc entries creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 10/29] mm: use non-racy method for /proc/swaps creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 11/29] sound: use non-racy method for /proc/driver/snd-page-alloc creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 12/29] zorro: use non-racy method for proc entries creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 13/29] samples: use non-racy method for /proc/marker-example creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 14/29] scsi: use non-racy method for proc entries creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 15/29] usb: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 16/29] s390: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 17/29] arm: use non-racy method for /proc/davinci_clocks creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 18/29] avr32: proc: use non-racy method for /proc/tlb creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 19/29] cris: use non-racy method for /proc/system_profile creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 20/29] ia64: use non-racy method for proc entries creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 21/29] parisc: use non-racy method for /proc/pcxl_dma creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 22/29] powerpc: use non-racy method for proc entries creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 23/29] acpi: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 24/29] net: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 25/29] isdn: " Denis V. Lunev
2008-04-30 17:57 ` [patch, -git] isdn: hysdn_procconf.c build fix Ingo Molnar
2008-04-30 18:10 ` Andrew Morton
2008-04-30 18:30 ` Ingo Molnar
2008-04-30 18:47 ` Andrew Morton
2008-04-30 19:03 ` Denis V. Lunev
2008-04-30 19:14 ` Andrew Morton
2008-04-30 19:24 ` Harvey Harrison
2008-04-30 21:21 ` Alexey Dobriyan
2008-04-08 11:19 ` [PATCH 26/29] kernel: use non-racy method for proc entries creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 27/29] parisc: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 28/29] drivers: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 29/29] " Denis V. Lunev
2008-04-17 17:13 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox