aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2009-12-16 16:31:33 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-23 14:23:42 -0500
commitf1f76f865b5f66db5b5c7f2d19874f2bb9b43b8d (patch)
tree39d051d6ad2c3560867c4553c93454f8972512bb
parentf42ecb2808db5386f983d593a7c08d3ea3b94a27 (diff)
devtmpfs: Convert dirlock to a mutex
devtmpfs has a rw_lock dirlock which serializes delete_path and create_path. This code was obviously never tested with the usual set of debugging facilities enabled. In the dirlock held sections the code calls: - vfs functions which take mutexes - kmalloc(, GFP_KERNEL) In both code pathes the might sleep warning triggers and spams dmesg. Convert the rw_lock to a mutex. There is no reason why this needs to be a rwlock. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/base/devtmpfs.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index 50375bb8e51d..278371c7bf5a 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -32,7 +32,7 @@ static int dev_mount = 1;
32static int dev_mount; 32static int dev_mount;
33#endif 33#endif
34 34
35static rwlock_t dirlock; 35static DEFINE_MUTEX(dirlock);
36 36
37static int __init mount_param(char *str) 37static int __init mount_param(char *str)
38{ 38{
@@ -93,7 +93,7 @@ static int create_path(const char *nodepath)
93{ 93{
94 int err; 94 int err;
95 95
96 read_lock(&dirlock); 96 mutex_lock(&dirlock);
97 err = dev_mkdir(nodepath, 0755); 97 err = dev_mkdir(nodepath, 0755);
98 if (err == -ENOENT) { 98 if (err == -ENOENT) {
99 char *path; 99 char *path;
@@ -117,7 +117,7 @@ static int create_path(const char *nodepath)
117 } 117 }
118 kfree(path); 118 kfree(path);
119 } 119 }
120 read_unlock(&dirlock); 120 mutex_unlock(&dirlock);
121 return err; 121 return err;
122} 122}
123 123
@@ -229,7 +229,7 @@ static int delete_path(const char *nodepath)
229 if (!path) 229 if (!path)
230 return -ENOMEM; 230 return -ENOMEM;
231 231
232 write_lock(&dirlock); 232 mutex_lock(&dirlock);
233 for (;;) { 233 for (;;) {
234 char *base; 234 char *base;
235 235
@@ -241,7 +241,7 @@ static int delete_path(const char *nodepath)
241 if (err) 241 if (err)
242 break; 242 break;
243 } 243 }
244 write_unlock(&dirlock); 244 mutex_unlock(&dirlock);
245 245
246 kfree(path); 246 kfree(path);
247 return err; 247 return err;
@@ -352,8 +352,6 @@ int __init devtmpfs_init(void)
352 int err; 352 int err;
353 struct vfsmount *mnt; 353 struct vfsmount *mnt;
354 354
355 rwlock_init(&dirlock);
356
357 err = register_filesystem(&dev_fs_type); 355 err = register_filesystem(&dev_fs_type);
358 if (err) { 356 if (err) {
359 printk(KERN_ERR "devtmpfs: unable to register devtmpfs " 357 printk(KERN_ERR "devtmpfs: unable to register devtmpfs "