linux/drivers/spi
Axel Lin 702a4879ec spi: bitbang: Let spi_bitbang_start() take a reference to master
Many drivers that use bitbang library have a leak on probe error paths.
This is because once a spi_master_get() call succeeds, we need an additional
spi_master_put() call to free the memory.

Fix this issue by moving the code taking a reference to master to
spi_bitbang_start(), so spi_bitbang_start() will take a reference to master on
success. With this change, the caller is responsible for calling
spi_bitbang_stop() to decrement the reference and spi_master_put() as
counterpart of spi_alloc_master() to prevent a memory leak.

So now we have below patten for drivers using bitbang library:

probe:
spi_alloc_master        -> Init reference count to 1
spi_bitbang_start       -> Increment reference count
remove:
spi_bitbang_stop        -> Decrement reference count
spi_master_put          -> Decrement reference count (reference count reaches 0)

Fixup all users accordingly.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Suggested-by: Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
Acked-by: Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-07 14:50:43 +01:00
..
Kconfig Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
Makefile Merge remote-tracking branch 'spi/topic/qspi' into spi-next 2013-09-01 13:49:06 +01:00
spi-altera.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi-ath79.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi-atmel.c spi/atmel: Fix format specifier warnings 2013-07-31 17:55:00 +01:00
spi-au1550.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi-bcm63xx.c Merge remote-tracking branch 'spi/topic/qspi' into spi-next 2013-09-01 13:49:06 +01:00
spi-bcm2835.c spi: bcm2835: Add spi_master_get() call to prevent use after free 2013-08-22 19:07:51 +01:00
spi-bfin5xx.c spi: use dev_get_platdata() 2013-08-29 13:56:23 +01:00
spi-bfin-sport.c spi: use dev_get_platdata() 2013-08-29 13:56:23 +01:00
spi-bfin-v3.c Merge remote-tracking branch 'spi/topic/pdata' into spi-next 2013-09-01 13:49:03 +01:00
spi-bitbang-txrx.h
spi-bitbang.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi-butterfly.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi-clps711x.c spi/clps711x: Remove unneeded devm_ deallocations 2013-07-15 11:36:33 +01:00
spi-coldfire-qspi.c Merge remote-tracking branch 'spi/topic/qspi' into spi-next 2013-09-01 13:49:06 +01:00
spi-davinci.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi-dw-mid.c
spi-dw-mmio.c spi: remove unnecessary platform_set_drvdata() 2013-05-13 18:00:30 +04:00
spi-dw-pci.c spi: Remove HOTPLUG section attributes 2012-12-07 17:06:43 +00:00
spi-dw.c spi: convert drivers to use bits_per_word_mask 2013-05-29 20:48:17 +01:00
spi-dw.h
spi-efm32.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi-ep93xx.c Merge remote-tracking branch 'spi/topic/pdata' into spi-next 2013-09-01 13:49:03 +01:00
spi-falcon.c spi/mips-lantiq: set SPI_MASTER_HALF_DUPLEX flag 2013-02-05 17:16:55 +00:00
spi-fsl-cpm.c spi/spi-fsl-spi: Make driver usable in CPU mode outside of an FSL_SOC environment 2013-04-07 10:07:54 +01:00
spi-fsl-cpm.h spi/spi-fsl-spi: Make driver usable in CPU mode outside of an FSL_SOC environment 2013-04-07 10:07:54 +01:00
spi-fsl-dspi.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi-fsl-espi.c spi: use dev_get_platdata() 2013-08-29 13:56:23 +01:00
spi-fsl-lib.c spi: use dev_get_platdata() 2013-08-29 13:56:23 +01:00
spi-fsl-lib.h spi/spi-fsl-spi: Add support for gpio chipselects for GRLIB type cores 2013-04-07 10:07:57 +01:00
spi-fsl-spi.c PTR_RET() is a weird name, and led to some confusing usage. We ended 2013-09-04 17:31:11 -07:00
spi-fsl-spi.h spi/spi-fsl-spi: Add support for Aeroflex Gaisler GRLIB cores normally running on SPARC 2013-04-07 10:07:56 +01:00
spi-gpio.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi-imx.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi-lm70llp.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi-mpc52xx-psc.c spi: use dev_get_platdata() 2013-08-29 13:56:23 +01:00
spi-mpc52xx.c spi: use platform_{get,set}_drvdata() 2013-05-23 09:09:55 -05:00
spi-mpc512x-psc.c Merge remote-tracking branch 'spi/topic/pdata' into spi-next 2013-09-01 13:49:03 +01:00
spi-mxs.c spi: spi-mxs: Remove unused bits_per_word variable 2013-08-06 18:06:29 +01:00
spi-nuc900.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi-oc-tiny.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi-octeon.c spi: octeon: Convert to use bits_per_word_mask 2013-08-20 11:34:08 +01:00
spi-omap2-mcspi.c Merge remote-tracking branch 'spi/topic/qspi' into spi-next 2013-09-01 13:49:06 +01:00
spi-omap-100k.c Merge remote-tracking branch 'spi/topic/pdata' into spi-next 2013-09-01 13:49:03 +01:00
spi-omap-uwire.c spi: use platform_{get,set}_drvdata() 2013-05-23 09:09:55 -05:00
spi-orion.c Merge remote-tracking branch 'spi/topic/orion' into spi-next 2013-09-01 13:49:02 +01:00
spi-pl022.c Merge remote-tracking branch 'spi/topic/qspi' into spi-next 2013-09-01 13:49:06 +01:00
spi-ppc4xx.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi-pxa2xx-dma.c Merge remote-tracking branch 'spi/topic/pxa' into spi-next 2013-06-26 16:21:03 +01:00
spi-pxa2xx-pci.c spi/pxa2xx-pci: correct the return value check of pcim_iomap_regions() 2013-03-12 18:30:56 +00:00
spi-pxa2xx-pxadma.c spi/pxa2xx: break out the private DMA API usage into a separate file 2013-02-08 12:15:21 +00:00
spi-pxa2xx.c Merge remote-tracking branch 'spi/topic/qspi' into spi-next 2013-09-01 13:49:06 +01:00
spi-pxa2xx.h spi/pxa2xx: add support for Intel Low Power Subsystem SPI 2013-02-08 13:14:40 +00:00
spi-rspi.c Merge remote-tracking branch 'spi/topic/rspi' into spi-next 2013-09-01 13:49:08 +01:00
spi-s3c24xx-fiq.h
spi-s3c24xx-fiq.S
spi-s3c24xx.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi-s3c64xx.c Merge remote-tracking branch 'spi/topic/s3c64xx' into spi-next 2013-09-01 13:49:09 +01:00
spi-sc18is602.c
spi-sh-hspi.c Merge remote-tracking branch 'spi/topic/sh-hspi' into spi-next 2013-09-01 13:49:10 +01:00
spi-sh-msiof.c Merge remote-tracking branch 'spi/topic/sh-msiof' into spi-next 2013-09-01 13:49:11 +01:00
spi-sh-sci.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi-sh.c spi: use platform_{get,set}_drvdata() 2013-05-23 09:09:55 -05:00
spi-sirf.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi-tegra20-sflash.c spi/tegra20-sflash: Use core runtime PM 2013-07-29 18:00:26 +01:00
spi-tegra20-slink.c spi/tegra20-slink: Use core runtime PM 2013-07-29 18:00:30 +01:00
spi-tegra114.c Merge remote-tracking branch 'spi/topic/tegra' into spi-next 2013-09-01 13:49:13 +01:00
spi-ti-qspi.c spi/qspi: fix missing unlock on error in ti_qspi_start_transfer_one() 2013-09-01 13:47:55 +01:00
spi-ti-ssp.c spi: use dev_get_platdata() 2013-08-29 13:56:23 +01:00
spi-tle62x0.c Merge remote-tracking branch 'spi/topic/tel62x0' into spi-next 2013-09-01 13:49:14 +01:00
spi-topcliff-pch.c spi-topcliff-pch: Add MODULE_DEVICE_TABLE 2013-08-13 01:00:51 +01:00
spi-txx9.c spi/txx9: Use linux/gpio.h not asm/gpio.h 2013-07-30 12:16:04 +01:00
spi-xcomm.c spi: convert drivers to use bits_per_word_mask 2013-05-29 20:48:17 +01:00
spi-xilinx.c spi: bitbang: Let spi_bitbang_start() take a reference to master 2013-10-07 14:50:43 +01:00
spi.c Merge remote-tracking branch 'spi/topic/quad' into spi-next 2013-09-01 13:49:07 +01:00
spidev.c PTR_RET is now PTR_ERR_OR_ZERO(): Replace most. 2013-07-15 11:25:01 +09:30