aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/oprofile
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/oprofile')
-rw-r--r--drivers/oprofile/event_buffer.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
index 2b7ae366ceb1..c38adb389064 100644
--- a/drivers/oprofile/event_buffer.c
+++ b/drivers/oprofile/event_buffer.c
@@ -41,6 +41,12 @@ static atomic_t buffer_ready = ATOMIC_INIT(0);
41 */ 41 */
42void add_event_entry(unsigned long value) 42void add_event_entry(unsigned long value)
43{ 43{
44 /*
45 * catch potential error
46 */
47 if (!event_buffer)
48 return;
49
44 if (buffer_pos == buffer_size) { 50 if (buffer_pos == buffer_size) {
45 atomic_inc(&oprofile_stats.event_lost_overflow); 51 atomic_inc(&oprofile_stats.event_lost_overflow);
46 return; 52 return;
@@ -92,9 +98,10 @@ out:
92 98
93void free_event_buffer(void) 99void free_event_buffer(void)
94{ 100{
101 mutex_lock(&buffer_mutex);
95 vfree(event_buffer); 102 vfree(event_buffer);
96
97 event_buffer = NULL; 103 event_buffer = NULL;
104 mutex_unlock(&buffer_mutex);
98} 105}
99 106
100 107
@@ -167,6 +174,11 @@ static ssize_t event_buffer_read(struct file *file, char __user *buf,
167 174
168 mutex_lock(&buffer_mutex); 175 mutex_lock(&buffer_mutex);
169 176
177 if (!event_buffer) {
178 retval = -EINTR;
179 goto out;
180 }
181
170 atomic_set(&buffer_ready, 0); 182 atomic_set(&buffer_ready, 0);
171 183
172 retval = -EFAULT; 184 retval = -EFAULT;