提交 4e95876e 编写于 作者: R Richard Weinberger 提交者: Xie XiuQi

mtd: core: Fix refcounting for unpartitioned MTDs

stable inclusion
from stable-5.10.4
commit d5e3fc275ea1f0f67f3b713cc866eb3248ae4080
bugzilla: 46903

--------------------------------

commit 1ca71415 upstream.

Apply changes to usecount also to the master partition.
Otherwise we have no refcounting at all if an MTD has no partitions.

Cc: stable@vger.kernel.org
Fixes: 46b5889c ("mtd: implement proper partition handling")
Signed-off-by: NRichard Weinberger <richard@nod.at>
Signed-off-by: NMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20201206202220.27290-1-richard@nod.atSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 1d42e44e
...@@ -993,6 +993,8 @@ int __get_mtd_device(struct mtd_info *mtd) ...@@ -993,6 +993,8 @@ int __get_mtd_device(struct mtd_info *mtd)
} }
} }
master->usecount++;
while (mtd->parent) { while (mtd->parent) {
mtd->usecount++; mtd->usecount++;
mtd = mtd->parent; mtd = mtd->parent;
...@@ -1059,6 +1061,8 @@ void __put_mtd_device(struct mtd_info *mtd) ...@@ -1059,6 +1061,8 @@ void __put_mtd_device(struct mtd_info *mtd)
mtd = mtd->parent; mtd = mtd->parent;
} }
master->usecount--;
if (master->_put_device) if (master->_put_device)
master->_put_device(master); master->_put_device(master);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册