aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/oprofile/oprofilefs.c
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2007-03-28 12:12:34 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-03-28 16:58:02 -0400
commit4dfc896e90359df04c80da5ab08ec31e87846c43 (patch)
tree1d68ae9c2e07c87f7cbc2f4b5c10d98a6c60a874 /drivers/oprofile/oprofilefs.c
parent6faee84b006af55bab9908741dd76916c8450be2 (diff)
[PATCH] oprofile: fix potential deadlock on oprofilefs_lock
nmi_cpu_setup() is called from hardirq context and acquires oprofilefs_lock. alloc_event_buffer() and oprofilefs_ulong_from_user() acquire this lock without disabling irqs, which could deadlock. Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/oprofile/oprofilefs.c')
-rw-r--r--drivers/oprofile/oprofilefs.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
index 6e67b42ca46d..8543cb26cf34 100644
--- a/drivers/oprofile/oprofilefs.c
+++ b/drivers/oprofile/oprofilefs.c
@@ -65,6 +65,7 @@ ssize_t oprofilefs_ulong_to_user(unsigned long val, char __user * buf, size_t co
65int oprofilefs_ulong_from_user(unsigned long * val, char const __user * buf, size_t count) 65int oprofilefs_ulong_from_user(unsigned long * val, char const __user * buf, size_t count)
66{ 66{
67 char tmpbuf[TMPBUFSIZE]; 67 char tmpbuf[TMPBUFSIZE];
68 unsigned long flags;
68 69
69 if (!count) 70 if (!count)
70 return 0; 71 return 0;
@@ -77,9 +78,9 @@ int oprofilefs_ulong_from_user(unsigned long * val, char const __user * buf, siz
77 if (copy_from_user(tmpbuf, buf, count)) 78 if (copy_from_user(tmpbuf, buf, count))
78 return -EFAULT; 79 return -EFAULT;
79 80
80 spin_lock(&oprofilefs_lock); 81 spin_lock_irqsave(&oprofilefs_lock, flags);
81 *val = simple_strtoul(tmpbuf, NULL, 0); 82 *val = simple_strtoul(tmpbuf, NULL, 0);
82 spin_unlock(&oprofilefs_lock); 83 spin_unlock_irqrestore(&oprofilefs_lock, flags);
83 return 0; 84 return 0;
84} 85}
85 86