Cc: Feng Tang <[email protected]>
Signed-off-by: Baruch Siach <[email protected]>
---
drivers/spi/spi-dw.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index e37dfc1..c3354e8 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -616,6 +616,7 @@ static int dw_spi_setup(struct spi_device *spi)
{
struct dw_spi_chip *chip_info = NULL;
struct chip_data *chip;
+ int ret;
/* Only alloc on first setup */
chip = spi_get_ctldata(spi);
@@ -656,7 +657,8 @@ static int dw_spi_setup(struct spi_device *spi)
if (!spi->max_speed_hz) {
dev_err(&spi->dev, "No max speed HZ parameter\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_kfree;
}
chip->speed_hz = spi->max_speed_hz;
@@ -669,6 +671,11 @@ static int dw_spi_setup(struct spi_device *spi)
spi_set_ctldata(spi, chip);
return 0;
+
+err_kfree:
+ kfree(chip);
+
+ return ret;
}
static void dw_spi_cleanup(struct spi_device *spi)
--
1.8.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html