Commit 43f627ac authored by Baruch Siach's avatar Baruch Siach Committed by Mark Brown

spi: dw: fix memory leak on error path

Signed-off-by: default avatarBaruch Siach <baruch@tkos.co.il>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 020fe3fe
...@@ -619,9 +619,11 @@ static int dw_spi_setup(struct spi_device *spi) ...@@ -619,9 +619,11 @@ static int dw_spi_setup(struct spi_device *spi)
/* Only alloc on first setup */ /* Only alloc on first setup */
chip = spi_get_ctldata(spi); chip = spi_get_ctldata(spi);
if (!chip) { if (!chip) {
chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL); chip = devm_kzalloc(&spi->dev, sizeof(struct chip_data),
GFP_KERNEL);
if (!chip) if (!chip)
return -ENOMEM; return -ENOMEM;
spi_set_ctldata(spi, chip);
} }
/* /*
...@@ -666,7 +668,6 @@ static int dw_spi_setup(struct spi_device *spi) ...@@ -666,7 +668,6 @@ static int dw_spi_setup(struct spi_device *spi)
| (spi->mode << SPI_MODE_OFFSET) | (spi->mode << SPI_MODE_OFFSET)
| (chip->tmode << SPI_TMOD_OFFSET); | (chip->tmode << SPI_TMOD_OFFSET);
spi_set_ctldata(spi, chip);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment