[PATCH] spi: bcm2835: fix reference leak to master in bcm2835_spi_remove()

Wei Yongjun weiyj.lk at gmail.com
Thu Nov 14 23:43:27 PST 2013

From: Wei Yongjun <yongjun_wei at trendmicro.com.cn>

Once a spi_master_get() call succeeds, we need an additional
spi_master_put() call to free the memory, otherwise we will
leak a reference to master. Fix by removing the unnecessary
spi_master_get() call.

Fixes: 247263dba208 ('spi: bcm2835: use devm_spi_register_master()')
Signed-off-by: Wei Yongjun <yongjun_wei at trendmicro.com.cn>
 drivers/spi/spi-bcm2835.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index 4c33214..3c5aca8 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -377,7 +377,7 @@ out_master_put:
 static int bcm2835_spi_remove(struct platform_device *pdev)
-	struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
+	struct spi_master *master = platform_get_drvdata(pdev);
 	struct bcm2835_spi *bs = spi_master_get_devdata(master);
 	free_irq(bs->irq, master);

More information about the linux-rpi-kernel mailing list