On 2026-09-23T21:40:27, João Loureiro <[email protected]> wrote:
> test: dm: sf: Get the emulator attached to the flash slave
>
> dm_test_spi_flash() picks up its SPI emulator with
> uclass_first_device_err(UCLASS_SPI_EMUL), which assumes the sandbox SPI
> flash emulator is the only device in that uclass. That holds today only
> because the flash emulator is bound lazily, on the first transfer.
>
> As soon as a second SPI emulator is described in the device tree it is
> bound during the devicetree scan and so comes first in the uclass. The
> test then hands a foreign device to sandbox_sf_set_block_protect(),
> which casts its private data to struct sandbox_spi_flash and writes
> past the end of it, corrupting the heap.
>
> Ask for the emulator attached to this particular slave instead, which
> is what the test means, and which stays correct however many SPI
> emulators exist.
>
> Signed-off-by: João Loureiro <[email protected]>
>
> test/dm/sf.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <[email protected]>

Reply via email to