linux-stable/drivers/mtd/spi-nor
Xiang Chen be94215be1 mtd: spi-nor: core: Fix an issue of releasing resources during read/write
If rmmod the driver during read or write, the driver will release the
resources which are used during read or write, so it is possible to
refer to NULL pointer.

Use the testcase "mtd_debug read /dev/mtd0 0xc00000 0x400000 dest_file &
sleep 0.5;rmmod spi_hisi_sfc_v3xx.ko", the issue can be reproduced in
hisi_sfc_v3xx driver.

To avoid the issue, fill the interface _get_device and _put_device of
mtd_info to grab the reference to the spi controller driver module, so
the request of rmmod the driver is rejected before read/write is finished.

Fixes: b199489d37 ("mtd: spi-nor: add the framework for SPI NOR")
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Tested-by: Michael Walle <michael@walle.cc>
Tested-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/1617262486-4223-1-git-send-email-yangyicong@hisilicon.com
2021-04-11 10:36:28 +03:00
..
controllers mtd: spi-nor: intel-spi: Move platform data header to x86 subfolder 2021-03-08 08:32:31 +02:00
atmel.c mtd: spi-nor: keep lock bits if they are non-volatile 2020-12-07 23:01:15 +05:30
catalyst.c mtd: spi-nor: Move Catalyst bits out of core.c 2020-03-17 09:28:05 +02:00
core.c mtd: spi-nor: core: Fix an issue of releasing resources during read/write 2021-04-11 10:36:28 +03:00
core.h mtd: spi-nor: implement OTP support for Winbond and similar flashes 2021-04-02 09:32:27 +03:00
eon.c mtd: spi-nor: Move Eon bits out of core.c 2020-03-17 09:28:02 +02:00
esmt.c mtd: spi-nor: keep lock bits if they are non-volatile 2020-12-07 23:01:15 +05:30
everspin.c mtd: spi-nor: Move Everspin bits out of core.c 2020-03-17 09:28:03 +02:00
fujitsu.c mtd: spi-nor: Move Fujitsu bits out of core.c 2020-03-17 09:28:03 +02:00
gigadevice.c mtd: spi-nor: Trim what is exposed in spi-nor.h 2020-03-17 09:28:07 +02:00
intel.c mtd: spi-nor: keep lock bits if they are non-volatile 2020-12-07 23:01:15 +05:30
issi.c mtd: spi-nor: Get rid of duplicated argument in spi_nor_parse_sfdp() 2021-03-15 18:01:47 +02:00
Kconfig mtd: spi-nor: keep lock bits if they are non-volatile 2020-12-07 23:01:15 +05:30
macronix.c mtd: spi-nor: Get rid of duplicated argument in spi_nor_parse_sfdp() 2021-03-15 18:01:47 +02:00
Makefile mtd: spi-nor: add OTP support 2021-04-02 09:30:15 +03:00
micron-st.c mtd: spi-nor: micron-st: allow using MT35XU512ABA in Octal DTR mode 2020-11-09 19:00:14 +05:30
otp.c mtd: spi-nor: implement OTP support for Winbond and similar flashes 2021-04-02 09:32:27 +03:00
sfdp.c mtd: spi-nor: Get rid of duplicated argument in spi_nor_parse_sfdp() 2021-03-15 18:01:47 +02:00
sfdp.h mtd: spi-nor: Get rid of duplicated argument in spi_nor_parse_sfdp() 2021-03-15 18:01:47 +02:00
spansion.c mtd: spi-nor: Get rid of duplicated argument in spi_nor_parse_sfdp() 2021-03-15 18:01:47 +02:00
sst.c mtd: spi-nor: sst: Add support for Global Unlock on sst26vf 2021-02-05 15:24:59 +02:00
swp.c mtd: spi-nor: swp: Improve code around spi_nor_check_lock_status_sr() 2021-03-31 22:41:34 +03:00
winbond.c mtd: spi-nor: winbond: add OTP support to w25q32fw/jw 2021-04-02 09:32:27 +03:00
xilinx.c mtd: spi-nor: Trim what is exposed in spi-nor.h 2020-03-17 09:28:07 +02:00
xmc.c mtd: spi-nor: Move XMC bits out of core.c 2020-03-17 09:28:06 +02:00