]> Git Repo - J-u-boot.git/commitdiff
dm: spi: Fix spi_free_slave() freed memory write
authorNiel Fourie <[email protected]>
Wed, 16 Dec 2020 11:11:52 +0000 (12:11 +0100)
committerSimon Glass <[email protected]>
Wed, 23 Dec 2020 03:39:26 +0000 (20:39 -0700)
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.

Signed-off-by: Niel Fourie <[email protected]>
Cc: Simon Glass <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
drivers/spi/spi-uclass.c

index acef09d6f47f3254bf049fd5d2c9e95be41e08b5..a392a93aa1b320dbcd50cbc0a3e06d42c724ce66 100644 (file)
@@ -435,7 +435,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_of_to_plat(struct udevice *dev, struct dm_spi_slave_plat *plat)
This page took 0.034956 seconds and 4 git commands to generate.