diff mbox

[U-Boot] spi: ftssp010_spi: Use to_ftssp010_spi() to ensure free correct address

Message ID 1423465869.10521.1.camel@phoenix
State Accepted
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Commit Message

Axel Lin Feb. 9, 2015, 7:11 a.m. UTC
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().

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/spi/ftssp010_spi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Jagan Teki Feb. 17, 2015, 8:46 a.m. UTC | #1
On 9 February 2015 at 12:41, Axel Lin <axel.lin@ingics.com> wrote:
> 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().
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>  drivers/spi/ftssp010_spi.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/spi/ftssp010_spi.c b/drivers/spi/ftssp010_spi.c
> index 267e4d8..c7d6480 100644
> --- a/drivers/spi/ftssp010_spi.c
> +++ b/drivers/spi/ftssp010_spi.c
> @@ -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)
> --
> 1.9.1
>
>
>

Applied to u-boot-spi/master

thanks!
diff mbox

Patch

diff --git a/drivers/spi/ftssp010_spi.c b/drivers/spi/ftssp010_spi.c
index 267e4d8..c7d6480 100644
--- a/drivers/spi/ftssp010_spi.c
+++ b/drivers/spi/ftssp010_spi.c
@@ -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)