diff options
Diffstat (limited to 'lib/dynamic_debug.c')
-rw-r--r-- | lib/dynamic_debug.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 86a9abb9a1ce..d8773dcd83c5 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c | |||
@@ -570,24 +570,32 @@ __setup("ddebug_query=", ddebug_setup_query); | |||
570 | * File_ops->write method for <debugfs>/dynamic_debug/conrol. Gathers the | 570 | * File_ops->write method for <debugfs>/dynamic_debug/conrol. Gathers the |
571 | * command text from userspace, parses and executes it. | 571 | * command text from userspace, parses and executes it. |
572 | */ | 572 | */ |
573 | #define USER_BUF_PAGE 4096 | ||
573 | static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf, | 574 | static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf, |
574 | size_t len, loff_t *offp) | 575 | size_t len, loff_t *offp) |
575 | { | 576 | { |
576 | char tmpbuf[256]; | 577 | char *tmpbuf; |
577 | int ret; | 578 | int ret; |
578 | 579 | ||
579 | if (len == 0) | 580 | if (len == 0) |
580 | return 0; | 581 | return 0; |
581 | /* we don't check *offp -- multiple writes() are allowed */ | 582 | if (len > USER_BUF_PAGE - 1) { |
582 | if (len > sizeof(tmpbuf)-1) | 583 | pr_warn("expected <%d bytes into control\n", USER_BUF_PAGE); |
583 | return -E2BIG; | 584 | return -E2BIG; |
584 | if (copy_from_user(tmpbuf, ubuf, len)) | 585 | } |
586 | tmpbuf = kmalloc(len + 1, GFP_KERNEL); | ||
587 | if (!tmpbuf) | ||
588 | return -ENOMEM; | ||
589 | if (copy_from_user(tmpbuf, ubuf, len)) { | ||
590 | kfree(tmpbuf); | ||
585 | return -EFAULT; | 591 | return -EFAULT; |
592 | } | ||
586 | tmpbuf[len] = '\0'; | 593 | tmpbuf[len] = '\0'; |
587 | if (verbose) | 594 | if (verbose) |
588 | pr_info("read %d bytes from userspace\n", (int)len); | 595 | pr_info("read %d bytes from userspace\n", (int)len); |
589 | 596 | ||
590 | ret = ddebug_exec_query(tmpbuf); | 597 | ret = ddebug_exec_query(tmpbuf); |
598 | kfree(tmpbuf); | ||
591 | if (ret) | 599 | if (ret) |
592 | return ret; | 600 | return ret; |
593 | 601 | ||