diff options
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/proc/stat.c | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/fs/proc/stat.c b/fs/proc/stat.c index 9d231e9e5f0e..bf2d03f8fd3e 100644 --- a/fs/proc/stat.c +++ b/fs/proc/stat.c | |||
| @@ -184,29 +184,11 @@ static int show_stat(struct seq_file *p, void *v) | |||
| 184 | 184 | ||
| 185 | static int stat_open(struct inode *inode, struct file *file) | 185 | static int stat_open(struct inode *inode, struct file *file) |
| 186 | { | 186 | { |
| 187 | size_t size = 1024 + 128 * num_possible_cpus(); | 187 | size_t size = 1024 + 128 * num_online_cpus(); |
| 188 | char *buf; | ||
| 189 | struct seq_file *m; | ||
| 190 | int res; | ||
| 191 | 188 | ||
| 192 | /* minimum size to display an interrupt count : 2 bytes */ | 189 | /* minimum size to display an interrupt count : 2 bytes */ |
| 193 | size += 2 * nr_irqs; | 190 | size += 2 * nr_irqs; |
| 194 | 191 | return single_open_size(file, show_stat, NULL, size); | |
| 195 | /* don't ask for more than the kmalloc() max size */ | ||
| 196 | if (size > KMALLOC_MAX_SIZE) | ||
| 197 | size = KMALLOC_MAX_SIZE; | ||
| 198 | buf = kmalloc(size, GFP_KERNEL); | ||
| 199 | if (!buf) | ||
| 200 | return -ENOMEM; | ||
| 201 | |||
| 202 | res = single_open(file, show_stat, NULL); | ||
| 203 | if (!res) { | ||
| 204 | m = file->private_data; | ||
| 205 | m->buf = buf; | ||
| 206 | m->size = ksize(buf); | ||
| 207 | } else | ||
| 208 | kfree(buf); | ||
| 209 | return res; | ||
| 210 | } | 192 | } |
| 211 | 193 | ||
| 212 | static const struct file_operations proc_stat_operations = { | 194 | static const struct file_operations proc_stat_operations = { |
