Skip to content

Commit 75d3f45

Browse files
kasjerkartben
authored andcommitted
tests: drivers: spi: spi_slave: Fix memory corruption
This fixes memory corruption of delayable work when tests executes unsupported function. When test (e.g. only_rx_in_chunks) is executed it starts delayed work for master functionality (with 10 ms delay). Later when slave function is tried and reports that function is unsupported, test is terminated (task ends) but work is still scheduled. When next test starts it clears work that is already scheduled: static void before(void *not_used) { ARG_UNUSED(not_used); memset(&tdata, 0, sizeof(tdata)); this leads to memory corruption and system work queue tries to remove work but it never does since head/next pointers are zeroed at that time. This just adds after function that cancels work regardless if it was scheduled or not. Signed-off-by: Jerzy Kasenberg <[email protected]>
1 parent c9a95dd commit 75d3f45

File tree

1 file changed

+8
-1
lines changed
  • tests/drivers/spi/spi_controller_peripheral/src

1 file changed

+8
-1
lines changed

tests/drivers/spi/spi_controller_peripheral/src/main.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,16 @@ static void before(void *not_used)
530530
k_sem_init(&tdata.sem, 0, 1);
531531
}
532532

533+
static void after(void *not_used)
534+
{
535+
ARG_UNUSED(not_used);
536+
537+
k_work_cancel_delayable(&tdata.test_work);
538+
}
539+
533540
static void *suite_setup(void)
534541
{
535542
return NULL;
536543
}
537544

538-
ZTEST_SUITE(spi_controller_peripheral, NULL, suite_setup, before, NULL, NULL);
545+
ZTEST_SUITE(spi_controller_peripheral, NULL, suite_setup, before, after, NULL);

0 commit comments

Comments
 (0)