[PATCH RESEND] mtd:spi-nor: Fix an issue of releasing resources during read/write
Yicong Yang
yangyicong at hisilicon.com
Thu Apr 8 12:10:54 BST 2021
On 2021/4/7 22:50, Michael Walle wrote:
> Hi,
>
> nit: subject should be "mtd: spi-nor: Fix.."
>
thanks. maybe Tudor can get this fixed, or i'll
send a v2 one.
> 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.
>
yes, it works. the ref count are get by the open() callback. thanks for the hint.
thanks
Yicong
> -michael
>
> .
More information about the linux-mtd
mailing list