Skip to contentSkip to conversation

spi: ftssp010_spi: Use to_ftssp010_spi() to ensure free correct address

U-Boot Axel Lin 2 participants 2 messages Feb 9, 2015 – Feb 17, 2015 SPI

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

Don't assume slave is always the first member of struct ftssp010_spi. Use to_ftssp010_spi() to ensure free correct address in spi_free_slave().

---
 drivers/spi/ftssp010_spi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/ftssp010_spi.c +3 -1
index 267e4d8..c7d6480 100644
@@ -431,7 +431,9 @@ free_out:
 
 void spi_free_slave(struct spi_slave *slave)
 {
-	free(slave);
+	struct ftssp010_spi *chip = to_ftssp010_spi(slave);
+
+	free(chip);
 }
 
 int spi_claim_bus(struct spi_slave *slave)
Signature · 1 line
1.9.1
#1 lore raw
Quoted 24 lines · Axel Lin

Don't assume slave is always the first member of struct ftssp010_spi. Use to_ftssp010_spi() to ensure free correct address in spi_free_slave().

---
 drivers/spi/ftssp010_spi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/ftssp010_spi.c +3 -2
index 267e4d8..c7d6480 100644
@@ -431,7 +431,9 @@ free_out:
 
 void spi_free_slave(struct spi_slave *slave)
 {
-       free(slave);
+       struct ftssp010_spi *chip = to_ftssp010_spi(slave);
+
+       free(chip);
 }
 
 int spi_claim_bus(struct spi_slave *slave)
--
Quoted 4 lines

1.9.1

Applied to u-boot-spi/master

thanks!

Signature · 1 line
Jagan.