Skip to contentSkip to conversation

spi: dw: Don't call kfree for memory allocated by devm_kzalloc

PATCH Superseded Axel Lin 2 participants 2 messages Mar 25, 2014 SPI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 spi: dw: Don't call kfree for memory allocated by devm_kzalloc

With devm_kzalloc, the memory is automatically freed when spi_device detach from the bus.

Fixes commit 04f421e7b0b1 (spi: dw: use managed resources)
---
 drivers/spi/spi-dw.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/spi/spi-dw.c +0 -7
index 8b7e4a3..712ac562 100644
@@ -664,12 +664,6 @@ static int dw_spi_setup(struct spi_device *spi)
 	return 0;
 }
 
-static void dw_spi_cleanup(struct spi_device *spi)
-{
-	struct chip_data *chip = spi_get_ctldata(spi);
-	kfree(chip);
-}
-
 static int init_queue(struct dw_spi *dws)
 {
 	INIT_LIST_HEAD(&dws->queue);
@@ -799,7 +793,6 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
 	master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
 	master->bus_num = dws->bus_num;
 	master->num_chipselect = dws->num_cs;
-	master->cleanup = dw_spi_cleanup;
 	master->setup = dw_spi_setup;
 	master->transfer = dw_spi_transfer;
 	master->max_speed_hz = dws->max_freq;
Signature · 8 lines
1.8.3.2



--
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
Acked-by on v1 1/1
#1 lore raw

Hi Axel Lin,

Quoted 4 lines · Axel Lin

With devm_kzalloc, the memory is automatically freed when spi_device detach from the bus.

Fixes commit 04f421e7b0b1 (spi: dw: use managed resources)

The devm_kzalloc for this struct was introduced in 43f627ac9de42 (spi: dw: fix memory leak on error path). Other than that:

Thanks,
baruch

Quoted 32 lines
---
 drivers/spi/spi-dw.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/spi/spi-dw.c +0 -7
index 8b7e4a3..712ac562 100644
@@ -664,12 +664,6 @@ static int dw_spi_setup(struct spi_device *spi)
 	return 0;
 }
 
-static void dw_spi_cleanup(struct spi_device *spi)
-{
-	struct chip_data *chip = spi_get_ctldata(spi);
-	kfree(chip);
-}
-
 static int init_queue(struct dw_spi *dws)
 {
 	INIT_LIST_HEAD(&dws->queue);
@@ -799,7 +793,6 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
 	master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
 	master->bus_num = dws->bus_num;
 	master->num_chipselect = dws->num_cs;
-	master->cleanup = dw_spi_cleanup;
 	master->setup = dw_spi_setup;
 	master->transfer = dw_spi_transfer;
 	master->max_speed_hz = dws->max_freq;
Signature · 1 line
1.8.3.2
Signature · 7 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -
--
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