aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/ipmi/ipmi_msghandler.c
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2009-03-25 15:48:06 -0400
committerAlexey Dobriyan <adobriyan@gmail.com>2009-03-30 17:14:44 -0400
commit99b76233803beab302123d243eea9e41149804f3 (patch)
tree398178210fe66845ccd6fa4258ba762a87e023ad /drivers/char/ipmi/ipmi_msghandler.c
parent3dec7f59c370c7b58184d63293c3dc984d475840 (diff)
proc 2/2: remove struct proc_dir_entry::owner
Setting ->owner as done currently (pde->owner = THIS_MODULE) is racy as correctly noted at bug #12454. Someone can lookup entry with NULL ->owner, thus not pinning enything, and release it later resulting in module refcount underflow. We can keep ->owner and supply it at registration time like ->proc_fops and ->data. But this leaves ->owner as easy-manipulative field (just one C assignment) and somebody will forget to unpin previous/pin current module when switching ->owner. ->proc_fops is declared as "const" which should give some thoughts. ->read_proc/->write_proc were just fixed to not require ->owner for protection. rmmod'ed directories will be empty and return "." and ".." -- no harm. And directories with tricky enough readdir and lookup shouldn't be modular. We definitely don't want such modular code. Removing ->owner will also make PDE smaller. So, let's nuke it. Kudos to Jeff Layton for reminding about this, let's say, oversight. http://bugzilla.kernel.org/show_bug.cgi?id=12454 Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Diffstat (limited to 'drivers/char/ipmi/ipmi_msghandler.c')
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 7a88dfd4427b..e93fc8d22fb2 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -1944,7 +1944,7 @@ static int stat_file_read_proc(char *page, char **start, off_t off,
1944 1944
1945int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, 1945int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
1946 read_proc_t *read_proc, 1946 read_proc_t *read_proc,
1947 void *data, struct module *owner) 1947 void *data)
1948{ 1948{
1949 int rv = 0; 1949 int rv = 0;
1950#ifdef CONFIG_PROC_FS 1950#ifdef CONFIG_PROC_FS
@@ -1970,7 +1970,6 @@ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
1970 } else { 1970 } else {
1971 file->data = data; 1971 file->data = data;
1972 file->read_proc = read_proc; 1972 file->read_proc = read_proc;
1973 file->owner = owner;
1974 1973
1975 mutex_lock(&smi->proc_entry_lock); 1974 mutex_lock(&smi->proc_entry_lock);
1976 /* Stick it on the list. */ 1975 /* Stick it on the list. */
@@ -1993,23 +1992,21 @@ static int add_proc_entries(ipmi_smi_t smi, int num)
1993 smi->proc_dir = proc_mkdir(smi->proc_dir_name, proc_ipmi_root); 1992 smi->proc_dir = proc_mkdir(smi->proc_dir_name, proc_ipmi_root);
1994 if (!smi->proc_dir) 1993 if (!smi->proc_dir)
1995 rv = -ENOMEM; 1994 rv = -ENOMEM;
1996 else
1997 smi->proc_dir->owner = THIS_MODULE;
1998 1995
1999 if (rv == 0) 1996 if (rv == 0)
2000 rv = ipmi_smi_add_proc_entry(smi, "stats", 1997 rv = ipmi_smi_add_proc_entry(smi, "stats",
2001 stat_file_read_proc, 1998 stat_file_read_proc,
2002 smi, THIS_MODULE); 1999 smi);
2003 2000
2004 if (rv == 0) 2001 if (rv == 0)
2005 rv = ipmi_smi_add_proc_entry(smi, "ipmb", 2002 rv = ipmi_smi_add_proc_entry(smi, "ipmb",
2006 ipmb_file_read_proc, 2003 ipmb_file_read_proc,
2007 smi, THIS_MODULE); 2004 smi);
2008 2005
2009 if (rv == 0) 2006 if (rv == 0)
2010 rv = ipmi_smi_add_proc_entry(smi, "version", 2007 rv = ipmi_smi_add_proc_entry(smi, "version",
2011 version_file_read_proc, 2008 version_file_read_proc,
2012 smi, THIS_MODULE); 2009 smi);
2013#endif /* CONFIG_PROC_FS */ 2010#endif /* CONFIG_PROC_FS */
2014 2011
2015 return rv; 2012 return rv;
@@ -4265,7 +4262,6 @@ static int ipmi_init_msghandler(void)
4265 return -ENOMEM; 4262 return -ENOMEM;
4266 } 4263 }
4267 4264
4268 proc_ipmi_root->owner = THIS_MODULE;
4269#endif /* CONFIG_PROC_FS */ 4265#endif /* CONFIG_PROC_FS */
4270 4266
4271 setup_timer(&ipmi_timer, ipmi_timeout, 0); 4267 setup_timer(&ipmi_timer, ipmi_timeout, 0);