CVE-2026-142843: spi: stm32: fix double free of SRAM buffer on MDMA fallback
In the Linux kernel, the following vulnerability has been resolved:
spi: stm32: fix double free of SRAM buffer on MDMA fallback
When the "rxm2m" MDMA channel cannot be obtained, the driver frees the SRAM buffer and falls back to DMA-only mode. However, sramrxbuf is left pointing to the freed buffer.
As a result, stm32spiunpreparemsg() may clear the released SRAM area, while stm32spiremove() or a later probe error path may free the buffer again, triggering BUGON() in genpoolfreeowner().
The probe error path also checks srampool instead of sramrxbuf. If the SRAM allocation failed and a later probe step fails, genpoolfree() may therefore be called with an unallocated buffer.
Clear sramrxbuf after freeing it on the MDMA fallback path and use the buffer pointer to determine whether cleanup is needed.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.63 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.4 - Configuration
On the MDMA fallback path, clear sram_rx_buf after freeing the SRAM buffer. In the probe error path, use sram_rx_buf to determine whether cleanup is needed instead of checking sram_pool.
Linux kernel stm32 SPI driver sram_rx_buf = NULL after freeing
Event History
Frequently Asked Questions
Which systems are exposed to the affected cleanup paths?
Systems using the STM32 SPI driver are exposed when the driver cannot obtain the "rxm2m" MDMA channel and falls back to DMA-only mode. A separate affected probe-error path can occur when SRAM allocation fails and a later probe step also fails.
What failures can result from the stale or unallocated SRAM buffer handling?
The message-unprepare path may clear SRAM that was already released, and device removal or a later probe error path may free it again, triggering BUG_ON() in gen_pool_free_owner(). In the allocation-failure case, the probe error path may call gen_pool_free() for a buffer that was never allocated.
What remediation is available?
The vulnerability is resolved by clearing sram_rx_buf after it is freed during MDMA fallback and by checking sram_rx_buf, rather than sram_pool, before cleanup. The referenced stable kernel commits contain the fix.