diff options
author | Axel Lin <axel.lin@ingics.com> | 2013-08-22 17:19:07 +0200 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-08-22 20:07:51 +0200 |
commit | 7bc003100b61cdfe0515fe907010fe822353d924 (patch) | |
tree | 9728df84bb395e8b7c14b5ba31c62e0cc8fb727d /drivers/spi/spi-bcm2835.c | |
parent | spi: bcm2835: Use SPI_BPW_MASK macro for bits_per_word_mask setting (diff) | |
download | linux-7bc003100b61cdfe0515fe907010fe822353d924.tar.xz linux-7bc003100b61cdfe0515fe907010fe822353d924.zip |
spi: bcm2835: Add spi_master_get() call to prevent use after free
The call to spi_unregister_master results in device memory being freed, it must
no longer be accessed afterwards. Thus call spi_master_get() to get an extra
reference to the device and call spi_master_put() only after the last access to
device data.
Note, current code has an extra spi_master_put() call in bcm2835_spi_remove().
Thus this patch just adds an spi_master_get() to balance the reference count.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi/spi-bcm2835.c')
-rw-r--r-- | drivers/spi/spi-bcm2835.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c index 7de617aba695..52c81481c5c7 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 = platform_get_drvdata(pdev); + struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); struct bcm2835_spi *bs = spi_master_get_devdata(master); free_irq(bs->irq, master); |