proc entries creation race
Subsystems (43)
cover proc entries creation race
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.
PATCH 1/29 proc: introduce proc_create_data to setup de->data
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.
--- fs/proc/generic.c | 8 +++++--- fs/proc/root.c | 2 +- include/linux/proc_fs.h | 17 +++++++++++++++-- 3 files changed, 21 insertions(+), 6 deletions(-)
fs/proc/generic.c +5 -3
@@ -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;
fs/proc/root.c +1 -1
@@ -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);
include/linux/proc_fs.h +15 -2
@@ -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,
Signature · 1 line
1.5.3.rc5
PATCH 2/29 nfsd: use proc_create to setup de->proc_fops
In reply to Denis V. LunevUse proc_create() to make sure that ->proc_fops be setup before gluing PDE to main tree.
--- fs/nfsd/nfsctl.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
fs/nfsd/nfsctl.c +2 -2
@@ -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 */
Signature · 1 line
1.5.3.rc5
PATCH 3/29 nfs: use proc_create to setup de->proc_fops
In reply to Denis V. LunevUse proc_create() to make sure that ->proc_fops be setup before gluing PDE to main tree.
--- fs/nfs/client.c | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-)
fs/nfs/client.c +6 -8
@@ -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:
Signature · 1 line
1.5.3.rc5
PATCH 4/29 afs: use non-racy method for proc entries creation
In reply to Denis V. LunevUse proc_create()/proc_create_data() to make sure that ->proc_fops and ->data be setup before gluing PDE to main tree.
--- fs/afs/proc.c | 33 ++++++++++++++------------------- 1 files changed, 14 insertions(+), 19 deletions(-)
fs/afs/proc.c +14 -19
@@ -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 ;
Signature · 1 line
1.5.3.rc5
PATCH 5/29 ext4: use non-racy method for proc entries creation
In reply to Denis V. LunevUse proc_create()/proc_create_data() to make sure that ->proc_fops and ->data be setup before gluing PDE to main tree.
--- fs/ext4/mballoc.c | 15 ++++----------- 1 files changed, 4 insertions(+), 11 deletions(-)
fs/ext4/mballoc.c +4 -11
@@ -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 ;
Signature · 1 line
1.5.3.rc5
PATCH 6/29 reiserfs: use non-racy method for proc entries creation
In reply to Denis V. LunevUse 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.
--- fs/reiserfs/procfs.c | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-)
fs/reiserfs/procfs.c +3 -6
@@ -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)
Signature · 1 line
1.5.3.rc5
PATCH 7/29 jbd2: use non-racy method for proc entries creation
In reply to Denis V. LunevUse proc_create()/proc_create_data() to make sure that ->proc_fops and ->data be setup before gluing PDE to main tree.
--- fs/jbd2/journal.c | 17 ++++------------- 1 files changed, 4 insertions(+), 13 deletions(-)
fs/jbd2/journal.c +4 -13
@@ -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); } }
Signature · 1 line
1.5.3.rc5
PATCH 8/29 proc: use non-racy method for /proc/page_owner creation
In reply to Denis V. LunevUse proc_create()/proc_create_data() to make sure that ->proc_fops and ->data be setup before gluing PDE to main tree.
--- fs/proc/proc_misc.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)
fs/proc/proc_misc.c +3 -5
@@ -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 }
Signature · 1 line
1.5.3.rc5
PATCH 9/29 sysvipc: use non-racy method for proc entries creation
In reply to Denis V. LunevUse proc_create_data() to make sure that ->proc_fops and ->data be setup before gluing PDE to main tree.
--- ipc/util.c | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-)
ipc/util.c +6 -7
@@ -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); } }
Signature · 1 line
1.5.3.rc5
PATCH 10/29 mm: use non-racy method for /proc/swaps creation
In reply to Denis V. LunevUse proc_create() to make sure that ->proc_fops be setup before gluing PDE to main tree.
--- mm/swapfile.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
mm/swapfile.c +1 -5
@@ -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);
Signature · 1 line
1.5.3.rc5
PATCH 11/29 sound: use non-racy method for /proc/driver/snd-page-alloc creation
In reply to Denis V. LunevUse proc_create() to make sure that ->proc_fops be setup before gluing PDE to main tree.
--- sound/core/memalloc.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
sound/core/memalloc.c +2 -3
@@ -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 ; }
Signature · 1 line
1.5.3.rc5
PATCH 12/29 zorro: use non-racy method for proc entries creation
In reply to Denis V. LunevUse 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.
--- drivers/zorro/proc.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
drivers/zorro/proc.c +4 -3
@@ -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 ; }
Signature · 1 line
1.5.3.rc5
PATCH 13/29 samples: use non-racy method for /proc/marker-example creation
In reply to Denis V. LunevUse proc_create() to make sure that ->proc_fops be setup before gluing PDE to main tree.
--- samples/markers/marker-example.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
samples/markers/marker-example.c +2 -4
@@ -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 ; }
Signature · 1 line
1.5.3.rc5
PATCH 14/29 scsi: use non-racy method for proc entries creation
In reply to Denis V. LunevUse 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.
--- drivers/scsi/scsi_proc.c | 4 ++-- drivers/scsi/sg.c | 12 ++++-------- 2 files changed, 6 insertions(+), 10 deletions(-)
drivers/scsi/scsi_proc.c +2 -2
@@ -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 ;
drivers/scsi/sg.c +4 -8
@@ -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 ; }
Signature · 1 line
1.5.3.rc5
PATCH 15/29 usb: use non-racy method for proc entries creation
In reply to Denis V. LunevUse proc_create()/proc_create_data() to make sure that ->proc_fops and ->data be setup before gluing PDE to main tree.
--- 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(-)
drivers/usb/gadget/at91_udc.c +2 -9
@@ -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)
drivers/usb/gadget/omap_udc.c +2 -5
@@ -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 )
drivers/usb/host/sl811-hcd.c +1 -9
@@ -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)
Signature · 1 line
1.5.3.rc5
PATCH 16/29 s390: use non-racy method for proc entries creation
In reply to Denis V. LunevUse proc_create() to make sure that ->proc_fops be setup before gluing PDE to main tree.
--- 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(-)
drivers/s390/block/dasd_proc.c +5 -5
@@ -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);
drivers/s390/char/tape_proc.c +3 -4
@@ -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 @@ voidtape_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 ; }/*
drivers/s390/cio/blacklist.c +2 -5
@@ -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 ; }
Signature · 1 line
1.5.3.rc5
PATCH 17/29 arm: use non-racy method for /proc/davinci_clocks creation
In reply to Denis V. LunevUse proc_create() to make sure that ->proc_fops be setup before gluing PDE to main tree.
--- arch/arm/mach-davinci/clock.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
arch/arm/mach-davinci/clock.c +1 -5
@@ -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 ; }
Signature · 1 line
1.5.3.rc5
PATCH 18/29 avr32: proc: use non-racy method for /proc/tlb creation
In reply to Denis V. LunevUse proc_create() to make sure that ->proc_fops be setup before gluing PDE to main tree.
--- arch/avr32/mm/tlb.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
arch/avr32/mm/tlb.c +1 -5
@@ -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);
Signature · 1 line
1.5.3.rc5
PATCH 19/29 cris: use non-racy method for /proc/system_profile creation
In reply to Denis V. LunevUse proc_create() to make sure that ->proc_fops be setup before gluing PDE to main tree.
--- arch/cris/kernel/profile.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/cris/kernel/profile.c +2 -2
@@ -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 ;
Signature · 1 line
1.5.3.rc5
PATCH 20/29 ia64: use non-racy method for proc entries creation
In reply to Denis V. LunevUse proc_create()/proc_create_data() to make sure that ->proc_fops and ->data be setup before gluing PDE to main tree.
--- 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(-)
arch/ia64/hp/common/sba_iommu.c +2 -4
@@ -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
arch/ia64/kernel/perfmon.c +1 -5
@@ -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)
arch/ia64/kernel/salinfo.c +4 -6
@@ -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 */
arch/ia64/sn/kernel/sn2/sn2_smp.c +3 -2
@@ -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 ; }
arch/ia64/sn/kernel/sn2/sn_proc_fs.c +10 -19
@@ -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 */
Signature · 1 line
1.5.3.rc5
PATCH 21/29 parisc: use non-racy method for /proc/pcxl_dma creation
In reply to Denis V. LunevUse proc_create() to make sure that ->proc_fops be setup before gluing PDE to main tree.
--- arch/parisc/kernel/pci-dma.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
arch/parisc/kernel/pci-dma.c +3 -4
@@ -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" ); }
Signature · 1 line
1.5.3.rc5
PATCH 22/29 powerpc: use non-racy method for proc entries creation
In reply to Denis V. LunevUse 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.
--- 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(-)
arch/powerpc/kernel/lparcfg.c +2 -4
@@ -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 ; }
arch/powerpc/kernel/proc_ppc64.c +2 -3
@@ -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 ; }
arch/powerpc/kernel/rtas-proc.c +14 -31
57 lines not on this page · raw message
arch/powerpc/kernel/rtas_flash.c +4 -9
@@ -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,
arch/powerpc/platforms/cell/spufs/sched.c +1 -2
@@ -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 );
arch/powerpc/platforms/cell/spufs/sputrace.c +1 -2
@@ -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];
arch/powerpc/platforms/iseries/lpevents.c +2 -6
@@ -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);
arch/powerpc/platforms/iseries/mf.c +3 -3
@@ -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);
arch/powerpc/platforms/iseries/proc.c +2 -6
@@ -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);
arch/powerpc/platforms/iseries/viopath.c +1 -6
@@ -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);
arch/powerpc/platforms/pseries/eeh.c +2 -8
@@ -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);
arch/powerpc/platforms/pseries/reconfig.c +2 -5
@@ -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 ; }
arch/powerpc/platforms/pseries/rtasd.c +3 -4
@@ -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 )
Signature · 1 line
1.5.3.rc5
PATCH 23/29 acpi: use non-racy method for proc entries creation
In reply to Denis V. LunevUse 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.
--- 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(-)
drivers/acpi/ac.c +4 -8
@@ -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 ; }
drivers/acpi/battery.c +5 -7
@@ -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 ; }
drivers/acpi/button.c +10 -14
@@ -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 ;
drivers/acpi/ec.c +3 -8
@@ -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 ; }
drivers/acpi/event.c +4 -4
@@ -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
drivers/acpi/fan.c +5 -9
@@ -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 ; }
drivers/acpi/power.c +4 -7
@@ -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 ; }
drivers/acpi/processor_core.c +15 -24
@@ -112,6 +112,7 @@ static struct acpi_driver acpi_processor_driver = {#define UNINSTALL_NOTIFY_HANDLER 2static 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 ; }
drivers/acpi/processor_idle.c +5 -8
@@ -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 ; }
drivers/acpi/processor_perflib.c +4 -9
@@ -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 ; }
drivers/acpi/processor_thermal.c +1 -0
@@ -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,
drivers/acpi/processor_throttling.c +1 -0
@@ -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,
drivers/acpi/sbs.c +9 -26
@@ -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 ; }
drivers/acpi/sleep/proc.c +9 -17
@@ -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 ; }
drivers/acpi/system.c +11 -16
@@ -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:
drivers/acpi/thermal.c +28 -39
121 lines not on this page · raw message
drivers/acpi/video.c +44 -68
210 lines not on this page · raw message
Signature · 1 line
1.5.3.rc5
PATCH 24/29 net: use non-racy method for proc entries creation
In reply to Denis V. LunevUse proc_create()/proc_create_data() to make sure that ->proc_fops and ->data be setup before gluing PDE to main tree.
--- 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(-)
drivers/net/bonding/bond_main.c +3 -6
@@ -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 ); } }
drivers/net/ibmveth.c +3 -6
@@ -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 ; }
drivers/net/irda/vlsi_ir.c +2 -3
@@ -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;
drivers/net/pppoe.c +1 -3
@@ -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 */
drivers/net/pppol2tp.c +2 -2
@@ -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 );
drivers/net/wireless/airo.c +32 -52
190 lines not on this page · raw message
Signature · 1 line
1.5.3.rc5
PATCH 25/29 isdn: use non-racy method for proc entries creation
In reply to Denis V. LunevUse 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.
--- 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(-)
drivers/isdn/capi/kcapi_proc.c +10 -14
@@ -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
drivers/isdn/divert/divert_procfs.c +2 -3
@@ -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 );
drivers/isdn/hardware/eicon/divasproc.c +2 -6
@@ -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 ); }
drivers/isdn/hysdn/hysdn_procconf.c +4 -5
@@ -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 */
drivers/isdn/hysdn/hysdn_proclog.c +4 -4
@@ -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));
Signature · 1 line
1.5.3.rc5
PATCH 1/1 isdn: hysdn_procconf.c build fix
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").
--- drivers/isdn/hysdn/hysdn_procconf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/isdn/hysdn/hysdn_procconf.c +2 -1
@@ -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 */
Andrew Morton
maintainerRe: [patch, -git] isdn: hysdn_procconf.c build fix
Quoted 3 lines · On Wed, 30 Apr 2008 19:57:40 +0200 Ingo Molnar <[email protected]> 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.
Re: [patch, -git] isdn: hysdn_procconf.c build fix
Quoted 7 lines · Andrew Morton
Quoted 3 lines · On Wed, 30 Apr 2008 19:57:40 +0200 Ingo Molnar <[email protected]> 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").
Quoted 7 lines
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_SMPbreaks 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
Andrew Morton
maintainerRe: [patch, -git] isdn: hysdn_procconf.c build fix
Quoted 16 lines · On Wed, 30 Apr 2008 20:30:51 +0200 Ingo Molnar <[email protected]> wrote:
Quoted 13 lines · Andrew Morton
Quoted 3 lines · On Wed, 30 Apr 2008 19:57:40 +0200 Ingo Molnar <[email protected]> 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
Quoted 7 lines
Quoted 1 line
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
Kconfigblack holes:make
drivers/isdn/hysdn/hysdn_procconf.o
That's daft, sorry. We shouldn't expect everyone to do stuff like that.
Quoted 6 lines
(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.
Re: [patch, -git] isdn: hysdn_procconf.c build fix
Quoted 36 lines · Andrew Morton
Quoted 16 lines · On Wed, 30 Apr 2008 20:30:51 +0200 Ingo Molnar <[email protected]> wrote:
Quoted 13 lines · Andrew Morton
Quoted 3 lines · On Wed, 30 Apr 2008 19:57:40 +0200 Ingo Molnar <[email protected]> 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_SMPQuoted 7 lines
Quoted 1 line
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
Kconfigblack holes:make
drivers/isdn/hysdn/hysdn_procconf.oThat's daft, sorry. We shouldn't expect everyone to do stuff like that.
Quoted 6 lines
(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.
Quoted 6 lines
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_ALLFOOCONFIGwhich can be tested at the appropriate places.
I think that the same should be applied to allyesconfig
Andrew Morton
maintainerRe: [patch, -git] isdn: hysdn_procconf.c build fix
Quoted 37 lines · On Wed, 30 Apr 2008 23:03:05 +0400 "Denis V. Lunev" <[email protected]> wrote:
Quoted 36 lines · Andrew Morton
Quoted 16 lines · On Wed, 30 Apr 2008 20:30:51 +0200 Ingo Molnar <[email protected]> wrote:
Quoted 13 lines · Andrew Morton
Quoted 3 lines · On Wed, 30 Apr 2008 19:57:40 +0200 Ingo Molnar <[email protected]> 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_SMPQuoted 7 lines
Quoted 1 line
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
Kconfigblack holes:make
drivers/isdn/hysdn/hysdn_procconf.oThat's daft, sorry. We shouldn't expect everyone to do stuff like that.
Quoted 6 lines
(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.
Quoted 8 lines
Quoted 6 lines
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_ALLFOOCONFIGwhich 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?)
Re: [patch, -git] isdn: hysdn_procconf.c build fix
Quoted 17 lines · Andrew Morton
Quoted 9 lines · On Wed, 30 Apr 2008 23:03:05 +0400 "Denis V. Lunev" <[email protected]> wrote:
Quoted 7 lines
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_ALLFOOCONFIGwhich 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.
Quoted 6 lines
Perhaps we should implement
CONFIG_ALLYESCONFIG,CONFIG_ALLMODCONFIGandCONFIG_ALLFOOCONFIG, whereALLFOOCONFIG = ALLYESCONFIG || ALLMODCONFIG(where FOO is renamed to something sensible, but what?)
ALLBUILDCONFIG
Harvey
Re: [patch, -git] isdn: hysdn_procconf.c build fix
Quoted 18 lines · Harvey Harrison
Quoted 17 lines · Andrew Morton
Quoted 9 lines · On Wed, 30 Apr 2008 23:03:05 +0400 "Denis V. Lunev" <[email protected]> wrote:
Quoted 7 lines
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_ALLFOOCONFIGwhich 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.
Quoted 8 lines
Quoted 6 lines
Perhaps we should implement
CONFIG_ALLYESCONFIG,CONFIG_ALLMODCONFIGandCONFIG_ALLFOOCONFIG, whereALLFOOCONFIG = 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.
PATCH 26/29 kernel: use non-racy method for proc entries creation
In reply to Denis V. LunevUse proc_create()/proc_create_data() to make sure that ->proc_fops and ->data be setup before gluing PDE to main tree.
--- 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(-)
kernel/configs.c +2 -2
@@ -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 ;
kernel/dma.c +1 -6
@@ -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 ; }
kernel/kallsyms.c +1 -5
@@ -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);
kernel/latencytop.c +1 -8
@@ -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);
kernel/lockdep_proc.c +4 -12
@@ -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 ;
kernel/profile.c +2 -2
@@ -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 ;
kernel/resource.c +2 -8
@@ -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);
kernel/sched_debug.c +1 -4
@@ -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 ; }
kernel/time/timer_list.c +1 -4
@@ -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);
kernel/time/timer_stats.c +1 -4
@@ -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);
Signature · 1 line
1.5.3.rc5
PATCH 27/29 parisc: use non-racy method for proc entries creation
In reply to Denis V. LunevUse proc_create() to make sure that ->proc_fops be setup before gluing PDE to main tree.
--- drivers/parisc/ccio-dma.c | 14 +++++--------- drivers/parisc/sba_iommu.c | 14 +++++--------- 2 files changed, 10 insertions(+), 18 deletions(-)
drivers/parisc/ccio-dma.c +5 -9
@@ -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++;
drivers/parisc/sba_iommu.c +5 -9
@@ -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 ;
Signature · 1 line
1.5.3.rc5
PATCH 28/29 drivers: use non-racy method for proc entries creation
In reply to Denis V. LunevUse proc_create()/proc_create_data() to make sure that ->proc_fops and ->data be setup before gluing PDE to main tree.
--- 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(-)
drivers/char/i8k.c +2 -4
@@ -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 ([email protected])\n" ,I8K_VERSION );
drivers/char/misc.c +15 -12
@@ -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);
drivers/char/rtc.c +2 -4
@@ -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
drivers/char/toshiba.c +1 -2
@@ -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
drivers/char/viotape.c +3 -6
@@ -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 ;
Signature · 1 line
1.5.3.rc5
PATCH 29/29 drivers: use non-racy method for proc entries creation
In reply to Denis V. LunevUse proc_create()/proc_create_data() to make sure that ->proc_fops and ->data be setup before gluing PDE to main tree.
--- 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(-)
drivers/block/pktcdvd.c +1 -6
@@ -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 ;
drivers/cdrom/viocd.c +3 -7
@@ -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:
drivers/ide/ide-proc.c +2 -5
@@ -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 )
drivers/input/input.c +4 -8
@@ -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);
drivers/md/md.c +1 -5
@@ -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 )
drivers/media/video/zoran_procfs.c +3 -4
@@ -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",
drivers/message/i2o/i2o_proc.c +2 -4
@@ -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++; }
drivers/misc/hdpuftrs/hdpu_cpustate.c +1 -4
@@ -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" );
drivers/misc/hdpuftrs/hdpu_nexus.c +4 -9
@@ -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 ;
drivers/pci/proc.c +6 -7
@@ -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);
drivers/pnp/isapnp/proc.c +3 -4
@@ -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 ; }
drivers/rapidio/rio.c +1 -5
@@ -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);
drivers/rtc/rtc-proc.c +3 -5
@@ -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; - } } }
Signature · 1 line
1.5.3.rc5
Re: [PATCH 29/29] drivers: use non-racy method for proc entries creation
Quoted 5 lines · 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 <[email protected]>CC Greg Kroah-Hartman <[email protected]>
No objections to the input change.
Signature · 1 line
Dmitry