dm: spi: Fix spi_free_slave() freed memory write
PATCH 1/1 dm: spi: Fix spi_free_slave() freed memory write
Remove setting slave->dev to NULL after the device_remove() call.
The slave pointer points to dev->parent_priv, which has already been freed by device_free(), called from device_remove() in the preceding line. Writing to slave->dev may cause corruption of the dlmalloc free chunk forward pointer of the previously freed chunk.
--- drivers/spi/spi-uclass.c | 1 - 1 file changed, 1 deletion(-)
drivers/spi/spi-uclass.c +0 -1
@@ -428,7 +428,6 @@ struct spi_slave *spi_setup_slave(unsigned int busnum, unsigned int cs,void spi_free_slave (struct spi_slave *slave) {device_remove (slave->dev,DM_REMOVE_NORMAL ); - slave->dev =NULL ; } int spi_slave_ofdata_to_platdata(struct udevice *dev,
Signature · 1 line
2.28.0
PATCH 1/1 dm: spi: Fix spi_free_slave() freed memory write
Quoted 8 lines · Niel Fourie
Remove setting
slave->devto NULL after thedevice_remove()call.The slave pointer points to
dev->parent_priv, which has already been freed bydevice_free(), called fromdevice_remove()in the preceding line. Writing toslave->devmay cause corruption of the dlmalloc free chunk forward pointer of the previously freed chunk.
Quoted 5 lines
Signed-off-by Niel Fourie <[email protected]>Cc Simon Glass <[email protected]>--- drivers/spi/spi-uclass.c | 1 - 1 file changed, 1 deletion(-)
PATCH 1/1 dm: spi: Fix spi_free_slave() freed memory write
Quoted 8 lines · Niel Fourie
Remove setting
slave->devto NULL after thedevice_remove()call.The slave pointer points to
dev->parent_priv, which has already been freed bydevice_free(), called fromdevice_remove()in the preceding line. Writing toslave->devmay cause corruption of the dlmalloc free chunk forward pointer of the previously freed chunk.
Quoted 5 lines
Signed-off-by Niel Fourie <[email protected]>Cc Simon Glass <[email protected]>--- drivers/spi/spi-uclass.c | 1 - 1 file changed, 1 deletion(-)
Applied to u-boot-dm/next, thanks!