[PATCH RESEND] mtd:spi-nor: Fix an issue of releasing resources during read/write
Michael Walle
michael at walle.cc
Wed Apr 7 15:50:02 BST 2021
Hi,
nit: subject should be "mtd: spi-nor: Fix.."
Am 2021-04-01 09:34, schrieb Yicong Yang:
> From: Xiang Chen <chenxiang66 at hisilicon.com>
>
> 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.
>
> Signed-off-by: Xiang Chen <chenxiang66 at hisilicon.com>
> Signed-off-by: Yicong Yang <yangyicong at hisilicon.com>
Reviewed-by: Michael Walle <michael at walle.cc>
Tested-by: Michael Walle <michael at walle.cc> [with spi-nxp-fspi and
spi-fsl-dspi]
btw. you can also do:
lsmod
exec 3<> /dev/mtd0
lsmod
and have a look at the ref count.
-michael
More information about the linux-mtd
mailing list