diff options
Diffstat (limited to 'lib/dynamic_debug.c')
-rw-r--r-- | lib/dynamic_debug.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c37aeacd7651..7288e38e1757 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c | |||
@@ -8,6 +8,7 @@ | |||
8 | * By Greg Banks <gnb@melbourne.sgi.com> | 8 | * By Greg Banks <gnb@melbourne.sgi.com> |
9 | * Copyright (c) 2008 Silicon Graphics Inc. All Rights Reserved. | 9 | * Copyright (c) 2008 Silicon Graphics Inc. All Rights Reserved. |
10 | * Copyright (C) 2011 Bart Van Assche. All Rights Reserved. | 10 | * Copyright (C) 2011 Bart Van Assche. All Rights Reserved. |
11 | * Copyright (C) 2013 Du, Changbin <changbin.du@gmail.com> | ||
11 | */ | 12 | */ |
12 | 13 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ | 14 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ |
@@ -24,6 +25,7 @@ | |||
24 | #include <linux/sysctl.h> | 25 | #include <linux/sysctl.h> |
25 | #include <linux/ctype.h> | 26 | #include <linux/ctype.h> |
26 | #include <linux/string.h> | 27 | #include <linux/string.h> |
28 | #include <linux/parser.h> | ||
27 | #include <linux/string_helpers.h> | 29 | #include <linux/string_helpers.h> |
28 | #include <linux/uaccess.h> | 30 | #include <linux/uaccess.h> |
29 | #include <linux/dynamic_debug.h> | 31 | #include <linux/dynamic_debug.h> |
@@ -147,7 +149,8 @@ static int ddebug_change(const struct ddebug_query *query, | |||
147 | list_for_each_entry(dt, &ddebug_tables, link) { | 149 | list_for_each_entry(dt, &ddebug_tables, link) { |
148 | 150 | ||
149 | /* match against the module name */ | 151 | /* match against the module name */ |
150 | if (query->module && strcmp(query->module, dt->mod_name)) | 152 | if (query->module && |
153 | !match_wildcard(query->module, dt->mod_name)) | ||
151 | continue; | 154 | continue; |
152 | 155 | ||
153 | for (i = 0; i < dt->num_ddebugs; i++) { | 156 | for (i = 0; i < dt->num_ddebugs; i++) { |
@@ -155,14 +158,16 @@ static int ddebug_change(const struct ddebug_query *query, | |||
155 | 158 | ||
156 | /* match against the source filename */ | 159 | /* match against the source filename */ |
157 | if (query->filename && | 160 | if (query->filename && |
158 | strcmp(query->filename, dp->filename) && | 161 | !match_wildcard(query->filename, dp->filename) && |
159 | strcmp(query->filename, kbasename(dp->filename)) && | 162 | !match_wildcard(query->filename, |
160 | strcmp(query->filename, trim_prefix(dp->filename))) | 163 | kbasename(dp->filename)) && |
164 | !match_wildcard(query->filename, | ||
165 | trim_prefix(dp->filename))) | ||
161 | continue; | 166 | continue; |
162 | 167 | ||
163 | /* match against the function */ | 168 | /* match against the function */ |
164 | if (query->function && | 169 | if (query->function && |
165 | strcmp(query->function, dp->function)) | 170 | !match_wildcard(query->function, dp->function)) |
166 | continue; | 171 | continue; |
167 | 172 | ||
168 | /* match against the format */ | 173 | /* match against the format */ |
@@ -263,14 +268,12 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords) | |||
263 | */ | 268 | */ |
264 | static inline int parse_lineno(const char *str, unsigned int *val) | 269 | static inline int parse_lineno(const char *str, unsigned int *val) |
265 | { | 270 | { |
266 | char *end = NULL; | ||
267 | BUG_ON(str == NULL); | 271 | BUG_ON(str == NULL); |
268 | if (*str == '\0') { | 272 | if (*str == '\0') { |
269 | *val = 0; | 273 | *val = 0; |
270 | return 0; | 274 | return 0; |
271 | } | 275 | } |
272 | *val = simple_strtoul(str, &end, 10); | 276 | if (kstrtouint(str, 10, val) < 0) { |
273 | if (end == NULL || end == str || *end != '\0') { | ||
274 | pr_err("bad line-number: %s\n", str); | 277 | pr_err("bad line-number: %s\n", str); |
275 | return -EINVAL; | 278 | return -EINVAL; |
276 | } | 279 | } |
@@ -343,14 +346,14 @@ static int ddebug_parse_query(char *words[], int nwords, | |||
343 | } | 346 | } |
344 | if (last) | 347 | if (last) |
345 | *last++ = '\0'; | 348 | *last++ = '\0'; |
346 | if (parse_lineno(first, &query->first_lineno) < 0) { | 349 | if (parse_lineno(first, &query->first_lineno) < 0) |
347 | pr_err("line-number is <0\n"); | ||
348 | return -EINVAL; | 350 | return -EINVAL; |
349 | } | ||
350 | if (last) { | 351 | if (last) { |
351 | /* range <first>-<last> */ | 352 | /* range <first>-<last> */ |
352 | if (parse_lineno(last, &query->last_lineno) | 353 | if (parse_lineno(last, &query->last_lineno) < 0) |
353 | < query->first_lineno) { | 354 | return -EINVAL; |
355 | |||
356 | if (query->last_lineno < query->first_lineno) { | ||
354 | pr_err("last-line:%d < 1st-line:%d\n", | 357 | pr_err("last-line:%d < 1st-line:%d\n", |
355 | query->last_lineno, | 358 | query->last_lineno, |
356 | query->first_lineno); | 359 | query->first_lineno); |