History

kcsan: test: don't put the expect array on the stack

Size of the 'expect' array in the __report_matches is 1536 bytes, which is exactly the default frame size warning limit of the xtensa architecture. As a result allmodconfig xtensa kernel builds with the gcc that does not support the compiler plugins (which otherwise would push the said warning limit to 2K) fail with the following message: kernel/kcsan/kcsan_test.c:257:1: error: the frame size of 1680 bytes is larger than 1536 bytes Fix it by dynamically allocating the 'expect' array.

Max Filippov committed 3 years ago

Commit 5b24ac21 parent 88603b61 file · +6 −1Browse files

Unified · Split

kernel/kcsan/kcsan_test.c+6−1
@@ -159,7 +159,7 @@ static bool __report_matches(const struct expect_report *r) · 158 unmodified lines
159159 const bool is_assert = (r->access[0].type | r->access[1].type) & KCSAN_ACCESS_ASSERT;
160160 bool ret = false;
161161 unsigned long flags;
162− typeof(observed.lines) expect;
162+ typeof(*observed.lines) *expect;
163163 const char *end;
164164 char *cur;
165165 int i;
@@ -168,6 +168,10 @@ static bool __report_matches(const struct expect_report *r) · 2 unmodified lines
168168 if (!report_available())
169169 return false;
170170
171+ expect = kmalloc(sizeof(observed.lines), GFP_KERNEL);
172+ if (WARN_ON(!expect))
173+ return false;
174+
171175 /* Generate expected report contents. */
172176
173177 /* Title */
@@ -253,6 +257,7 @@ static bool __report_matches(const struct expect_report *r) · 79 unmodified lines
253257 strstr(observed.lines[2], expect[1])));
254258 out:
255259 spin_unlock_irqrestore(&observed.lock, flags);
260+ kfree(expect);
256261 return ret;
257262 }
258263