diff options
Diffstat (limited to 'lib/kunit/executor.c')
| -rw-r--r-- | lib/kunit/executor.c | 12 | 
1 files changed, 3 insertions, 9 deletions
| diff --git a/lib/kunit/executor.c b/lib/kunit/executor.c index 70b9a43cd257..34b7b6833df3 100644 --- a/lib/kunit/executor.c +++ b/lib/kunit/executor.c @@ -70,32 +70,26 @@ struct kunit_glob_filter {  static int kunit_parse_glob_filter(struct kunit_glob_filter *parsed,  				    const char *filter_glob)  { -	const int len = strlen(filter_glob);  	const char *period = strchr(filter_glob, '.');  	if (!period) { -		parsed->suite_glob = kzalloc(len + 1, GFP_KERNEL); +		parsed->suite_glob = kstrdup(filter_glob, GFP_KERNEL);  		if (!parsed->suite_glob)  			return -ENOMEM; -  		parsed->test_glob = NULL; -		strcpy(parsed->suite_glob, filter_glob);  		return 0;  	} -	parsed->suite_glob = kzalloc(period - filter_glob + 1, GFP_KERNEL); +	parsed->suite_glob = kstrndup(filter_glob, period - filter_glob, GFP_KERNEL);  	if (!parsed->suite_glob)  		return -ENOMEM; -	parsed->test_glob = kzalloc(len - (period - filter_glob) + 1, GFP_KERNEL); +	parsed->test_glob = kstrdup(period + 1, GFP_KERNEL);  	if (!parsed->test_glob) {  		kfree(parsed->suite_glob);  		return -ENOMEM;  	} -	strncpy(parsed->suite_glob, filter_glob, period - filter_glob); -	strncpy(parsed->test_glob, period + 1, len - (period - filter_glob)); -  	return 0;  } |