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
This commit is contained in:
Tomas Winkler
2023-06-20 16:19:04 +03:00
committed by Miquel Raynal
parent 06c2afb862
commit 19bfa9ebeb
4 changed files with 49 additions and 40 deletions

View File

@@ -379,7 +379,7 @@ struct mtd_info {
struct module *owner;
struct device dev;
int usecount;
struct kref refcnt;
struct mtd_debug_info dbg;
struct nvmem_device *nvmem;
struct nvmem_device *otp_user_nvmem;