[PATCH] cmd: sf: fix sf probe using non-flash device as flash handle

Peng Fan (OSS) peng.fan at oss.nxp.com
Tue Jun 9 12:55:35 CEST 2026


> Subject: [PATCH] cmd: sf: fix sf probe using non-flash device as flash
> handle
> 
> `sf probe` calls spi_flash_probe_bus_cs() which returns whatever device
> matches the given chip select, regardless of its type. On boards where a
> non-flash device (e.g. MMC) shares the SPI bus at cs 0, `sf probe 0`
> would silently use that device as a flash handle, causing undefined
> behavior.
> 
> Check that the returned device belongs to UCLASS_SPI_FLASH before
> dereferencing its uclass private data.
> 
> Fixes: fbb099183e3a ("dm: Convert spi_flash_probe() and 'sf probe' to
> use driver model")
> Signed-off-by: Nia Su <nia.su at sifive.com>

Looks correct to me.

Reviewed-by: Peng Fan <peng.fan at nxp.com>


More information about the U-Boot mailing list