Skip to content

Commit

Permalink
spi: dw: fix memory leak on error path
Browse files Browse the repository at this point in the history
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Baruch Siach authored and Mark Brown committed Dec 31, 2013
1 parent 020fe3f commit 43f627a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/spi/spi-dw.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,11 @@ static int dw_spi_setup(struct spi_device *spi)
/* Only alloc on first setup */
chip = spi_get_ctldata(spi);
if (!chip) {
chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL);
chip = devm_kzalloc(&spi->dev, sizeof(struct chip_data),
GFP_KERNEL);
if (!chip)
return -ENOMEM;
spi_set_ctldata(spi, chip);
}

/*
Expand Down Expand Up @@ -666,7 +668,6 @@ static int dw_spi_setup(struct spi_device *spi)
| (spi->mode << SPI_MODE_OFFSET)
| (chip->tmode << SPI_TMOD_OFFSET);

spi_set_ctldata(spi, chip);
return 0;
}

Expand Down

0 comments on commit 43f627a

Please sign in to comment.