Skip to contentSkip to conversation

spi: sun6i: Fix memory leak on device removal

PATCH In review Woody Zhang 2 participants 3 messages Oct 2, 2023 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/2 spi: sun6i: Fix memory leak on device removal

Call spi_master_put to free the spi_master structure on device removal and driver detachment.

---
 drivers/spi/spi-sun6i.c | 1 +
 1 file changed, 1 insertion(+)
drivers/spi/spi-sun6i.c +1 -0
index fddc63309773..33cec49d5538 100644
@@ -774,6 +774,7 @@ static void sun6i_spi_remove(struct platform_device *pdev)
 		dma_release_channel(master->dma_tx);
 	if (master->dma_rx)
 		dma_release_channel(master->dma_rx);
+	spi_master_put(master);
 }
 
 static const struct sun6i_spi_cfg sun6i_a31_spi_cfg = {
Signature · 1 line
2.39.2
#2 lore raw

PATCH 2/2 spi: sun4i: Fix memory leak on device removal

In reply to a message not in the archive

Call spi_master_put to free the spi_master structure on device removal and driver detachment.

---
 drivers/spi/spi-sun4i.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/spi/spi-sun4i.c +3 -0
index b8947265d329..ba5690039f72 100644
@@ -518,7 +518,10 @@ static int sun4i_spi_probe(struct platform_device *pdev)
 
 static void sun4i_spi_remove(struct platform_device *pdev)
 {
+	struct spi_master *master = dev_get_drvdata(&pdev->dev);
+
 	pm_runtime_force_suspend(&pdev->dev);
+	spi_master_put(master);
 }
 
 static const struct of_device_id sun4i_spi_match[] = {
Signature · 7 lines
2.39.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer
#3 lore raw

Re: [PATCH 2/2] spi: sun4i: Fix memory leak on device removal

drivers/spi/spi-sun4i.c static int sun4i_spi_probe(struct platform_device *pdev) · line 525

Quoted 10 lines · Woody Zhang

Call spi_master_put to free the spi_master structure on device removal and driver detachment.

static void sun4i_spi_remove(struct platform_device *pdev) {

drivers/spi/spi-sun4i.c +3 -0
+	struct spi_master *master = dev_get_drvdata(&pdev->dev);
+
 	pm_runtime_force_suspend(&pdev->dev);
+	spi_master_put(master);
 }

This is just obviously buggy, it doesn't match the registration at all.