linux/drivers/spi
Lukas Wunner 3e538c536f spi: Prevent adding devices below an unregistering controller
commit ddf75be47c upstream.

CONFIG_OF_DYNAMIC and CONFIG_ACPI allow adding SPI devices at runtime
using a DeviceTree overlay or DSDT patch.  CONFIG_SPI_SLAVE allows the
same via sysfs.

But there are no precautions to prevent adding a device below a
controller that's being removed.  Such a device is unusable and may not
even be able to unbind cleanly as it becomes inaccessible once the
controller has been torn down.  E.g. it is then impossible to quiesce
the device's interrupt.

of_spi_notify() and acpi_spi_notify() do hold a ref on the controller,
but otherwise run lockless against spi_unregister_controller().

Fix by holding the spi_add_lock in spi_unregister_controller() and
bailing out of spi_add_device() if the controller has been unregistered
concurrently.

Fixes: ce79d54ae4 ("spi/of: Add OF notifier handler")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: stable@vger.kernel.org # v3.19+
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Octavian Purdila <octavian.purdila@intel.com>
Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Link: https://lore.kernel.org/r/a8c3205088a969dc8410eec1eba9aface60f36af.1596451035.git.lukas@wunner.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-26 10:40:50 +02:00
..
atmel-quadspi.c
internals.h
Kconfig spi: Prevent adding devices below an unregistering controller 2020-08-26 10:40:50 +02:00
Makefile
spi-altera.c
spi-armada-3700.c
spi-at91-usart.c
spi-ath79.c
spi-atmel.c
spi-au1550.c
spi-axi-spi-engine.c
spi-bcm63xx-hsspi.c
spi-bcm63xx.c
spi-bcm2835.c
spi-bcm2835aux.c
spi-bcm-qspi.c
spi-bcm-qspi.h
spi-bitbang-txrx.h
spi-bitbang.c
spi-brcmstb-qspi.c
spi-butterfly.c
spi-cadence.c
spi-cavium-octeon.c
spi-cavium-thunderx.c
spi-cavium.c
spi-cavium.h
spi-clps711x.c
spi-coldfire-qspi.c
spi-davinci.c
spi-dln2.c
spi-dw-mid.c
spi-dw-mmio.c
spi-dw-pci.c
spi-dw.c
spi-dw.h
spi-efm32.c
spi-ep93xx.c
spi-falcon.c
spi-fsl-cpm.c
spi-fsl-cpm.h
spi-fsl-dspi.c spi: spi-fsl-dspi: Fix lockup if device is shutdown during SPI transfer 2020-07-22 09:32:55 +02:00
spi-fsl-espi.c
spi-fsl-lib.c
spi-fsl-lib.h
spi-fsl-lpspi.c
spi-fsl-qspi.c
spi-fsl-spi.c
spi-fsl-spi.h
spi-geni-qcom.c
spi-gpio.c
spi-img-spfi.c
spi-imx.c
spi-iproc-qspi.c
spi-jcore.c
spi-lantiq-ssc.c spi: lantiq-ssc: Fix warning by using WQ_MEM_RECLAIM 2020-08-19 08:16:14 +02:00
spi-lm70llp.c
spi-loopback-test.c
spi-lp8841-rtc.c
spi-mem.c
spi-meson-spicc.c
spi-meson-spifc.c
spi-mpc52xx-psc.c
spi-mpc52xx.c
spi-mpc512x-psc.c
spi-mt65xx.c spi: mediatek: use correct SPI_CFG2_REG MACRO 2020-07-29 10:18:37 +02:00
spi-mt7621.c
spi-mxic.c
spi-mxs.c
spi-npcm-fiu.c
spi-npcm-pspi.c
spi-nxp-fspi.c
spi-oc-tiny.c
spi-omap2-mcspi.c
spi-omap-100k.c
spi-omap-uwire.c
spi-orion.c
spi-pic32-sqi.c
spi-pic32.c
spi-pl022.c
spi-ppc4xx.c
spi-pxa2xx-dma.c
spi-pxa2xx-pci.c
spi-pxa2xx.c
spi-pxa2xx.h
spi-qcom-qspi.c
spi-qup.c
spi-rb4xx.c
spi-rockchip.c spi: rockchip: Fix error in SPI slave pio read 2020-08-19 08:15:58 +02:00
spi-rspi.c
spi-s3c24xx-fiq.h
spi-s3c24xx-fiq.S
spi-s3c24xx.c
spi-s3c64xx.c
spi-sc18is602.c
spi-sh-hspi.c
spi-sh-msiof.c
spi-sh-sci.c
spi-sh.c
spi-sifive.c
spi-sirf.c
spi-slave-mt27xx.c
spi-slave-system-control.c
spi-slave-time.c
spi-sprd-adi.c spi: sprd: switch the sequence of setting WDG_LOAD_LOW and _HIGH 2020-07-22 09:33:18 +02:00
spi-sprd.c
spi-st-ssc4.c
spi-stm32-qspi.c
spi-stm32.c
spi-sun4i.c
spi-sun6i.c spi: spi-sun6i: sun6i_spi_transfer_one(): fix setting of clock rate 2020-07-22 09:33:02 +02:00
spi-synquacer.c
spi-tegra20-sflash.c
spi-tegra20-slink.c
spi-tegra114.c
spi-test.h
spi-ti-qspi.c
spi-tle62x0.c
spi-topcliff-pch.c
spi-txx9.c
spi-uniphier.c
spi-xcomm.c
spi-xilinx.c
spi-xlp.c
spi-xtensa-xtfpga.c
spi-zynq-qspi.c
spi-zynqmp-gqspi.c
spi.c spi: Prevent adding devices below an unregistering controller 2020-08-26 10:40:50 +02:00
spidev.c spi: spidev: Align buffers for DMA 2020-08-19 08:16:25 +02:00