mtd: use refcount to prevent corruption
authorTomas Winkler <tomas.winkler@intel.com>
Tue, 20 Jun 2023 13:19:04 +0000 (16:19 +0300)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 12 Jul 2023 11:30:08 +0000 (13:30 +0200)
commit19bfa9ebebb5ec0695def57eb1d80de7e9cab369
treefa26bdecb34162685d5dfeee7ef9d442d7345f9c
parent06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5
mtd: use refcount to prevent corruption

When underlying device is removed mtd core will crash
in case user space is holding open handle.
Need to use proper refcounting so device is release
only when has no users.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230620131905.648089-2-alexander.usyskin@intel.com
drivers/mtd/mtdcore.c
drivers/mtd/mtdcore.h
drivers/mtd/mtdpart.c
include/linux/mtd/mtd.h