diff options
Diffstat (limited to 'fs/proc/generic.c')
-rw-r--r-- | fs/proc/generic.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index b7f268eb5f45..317b72641ebf 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c | |||
@@ -27,7 +27,7 @@ | |||
27 | 27 | ||
28 | #include "internal.h" | 28 | #include "internal.h" |
29 | 29 | ||
30 | DEFINE_SPINLOCK(proc_subdir_lock); | 30 | static DEFINE_SPINLOCK(proc_subdir_lock); |
31 | 31 | ||
32 | static int proc_match(unsigned int len, const char *name, struct proc_dir_entry *de) | 32 | static int proc_match(unsigned int len, const char *name, struct proc_dir_entry *de) |
33 | { | 33 | { |
@@ -330,28 +330,28 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent, | |||
330 | nlink_t nlink) | 330 | nlink_t nlink) |
331 | { | 331 | { |
332 | struct proc_dir_entry *ent = NULL; | 332 | struct proc_dir_entry *ent = NULL; |
333 | const char *fn = name; | 333 | const char *fn; |
334 | unsigned int len; | 334 | struct qstr qstr; |
335 | |||
336 | /* make sure name is valid */ | ||
337 | if (!name || !strlen(name)) | ||
338 | goto out; | ||
339 | 335 | ||
340 | if (xlate_proc_name(name, parent, &fn) != 0) | 336 | if (xlate_proc_name(name, parent, &fn) != 0) |
341 | goto out; | 337 | goto out; |
338 | qstr.name = fn; | ||
339 | qstr.len = strlen(fn); | ||
340 | if (qstr.len == 0 || qstr.len >= 256) { | ||
341 | WARN(1, "name len %u\n", qstr.len); | ||
342 | return NULL; | ||
343 | } | ||
344 | if (*parent == &proc_root && name_to_int(&qstr) != ~0U) { | ||
345 | WARN(1, "create '/proc/%s' by hand\n", qstr.name); | ||
346 | return NULL; | ||
347 | } | ||
342 | 348 | ||
343 | /* At this point there must not be any '/' characters beyond *fn */ | 349 | ent = kzalloc(sizeof(struct proc_dir_entry) + qstr.len + 1, GFP_KERNEL); |
344 | if (strchr(fn, '/')) | ||
345 | goto out; | ||
346 | |||
347 | len = strlen(fn); | ||
348 | |||
349 | ent = kzalloc(sizeof(struct proc_dir_entry) + len + 1, GFP_KERNEL); | ||
350 | if (!ent) | 350 | if (!ent) |
351 | goto out; | 351 | goto out; |
352 | 352 | ||
353 | memcpy(ent->name, fn, len + 1); | 353 | memcpy(ent->name, fn, qstr.len + 1); |
354 | ent->namelen = len; | 354 | ent->namelen = qstr.len; |
355 | ent->mode = mode; | 355 | ent->mode = mode; |
356 | ent->nlink = nlink; | 356 | ent->nlink = nlink; |
357 | atomic_set(&ent->count, 1); | 357 | atomic_set(&ent->count, 1); |