dynamic_debug: fix ddebug_parse_query()
authorAndrey Ryabinin <a.ryabinin@samsung.com>
Tue, 28 Jan 2014 01:06:58 +0000 (17:06 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 28 Jan 2014 05:02:39 +0000 (21:02 -0800)
This fixes following scenario:

  $ echo 'file dynamic_debug.c line 1-123 +p' > /sys/kernel/debug/dynamic_debug/control
  -bash: echo: write error: Invalid argument
  $ dmesg | grep dynamic_debug
  dynamic_debug:ddebug_parse_query: last-line:123 < 1st-line:1
  dynamic_debug:ddebug_parse_query: query parse failed

Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
Cc: Jason Baron <jbaron@akamai.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/dynamic_debug.c

index f959c39cc0079ee14cf226677b4c5063c3236427..e488d9a03adcdac5720f6bfb9a75d714b628b0ea 100644 (file)
@@ -352,8 +352,10 @@ static int ddebug_parse_query(char *words[], int nwords,
                                return -EINVAL;
                        if (last) {
                                /* range <first>-<last> */
-                               if (parse_lineno(last, &query->last_lineno)
-                                   < query->first_lineno) {
+                               if (parse_lineno(last, &query->last_lineno) < 0)
+                                       return -EINVAL;
+
+                               if (query->last_lineno < query->first_lineno) {
                                        pr_err("last-line:%d < 1st-line:%d\n",
                                                query->last_lineno,
                                                query->first_lineno);