@@ -65,24 +65,36 @@ struct kunit_glob_filter {
65
65
};
66
66
67
67
/* Split "suite_glob.test_glob" into two. Assumes filter_glob is not empty. */
68
- static void kunit_parse_glob_filter (struct kunit_glob_filter * parsed ,
68
+ static int kunit_parse_glob_filter (struct kunit_glob_filter * parsed ,
69
69
const char * filter_glob )
70
70
{
71
71
const int len = strlen (filter_glob );
72
72
const char * period = strchr (filter_glob , '.' );
73
73
74
74
if (!period ) {
75
75
parsed -> suite_glob = kzalloc (len + 1 , GFP_KERNEL );
76
+ if (!parsed -> suite_glob )
77
+ return - ENOMEM ;
78
+
76
79
parsed -> test_glob = NULL ;
77
80
strcpy (parsed -> suite_glob , filter_glob );
78
- return ;
81
+ return 0 ;
79
82
}
80
83
81
84
parsed -> suite_glob = kzalloc (period - filter_glob + 1 , GFP_KERNEL );
85
+ if (!parsed -> suite_glob )
86
+ return - ENOMEM ;
87
+
82
88
parsed -> test_glob = kzalloc (len - (period - filter_glob ) + 1 , GFP_KERNEL );
89
+ if (!parsed -> test_glob ) {
90
+ kfree (parsed -> suite_glob );
91
+ return - ENOMEM ;
92
+ }
83
93
84
94
strncpy (parsed -> suite_glob , filter_glob , period - filter_glob );
85
95
strncpy (parsed -> test_glob , period + 1 , len - (period - filter_glob ));
96
+
97
+ return 0 ;
86
98
}
87
99
88
100
/* Create a copy of suite with only tests that match test_glob. */
@@ -152,8 +164,11 @@ kunit_filter_suites(const struct kunit_suite_set *suite_set,
152
164
}
153
165
copy_start = copy ;
154
166
155
- if (filter_glob )
156
- kunit_parse_glob_filter (& parsed_glob , filter_glob );
167
+ if (filter_glob ) {
168
+ * err = kunit_parse_glob_filter (& parsed_glob , filter_glob );
169
+ if (* err )
170
+ goto free_copy ;
171
+ }
157
172
158
173
/* Parse attribute filters */
159
174
if (filters ) {
0 commit comments