mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-21 01:51:18 +00:00
mtd: core: Fix refcounting for unpartitioned MTDs
commit1ca71415f0
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:46b5889cc2
("mtd: implement proper partition handling") Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20201206202220.27290-1-richard@nod.at Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
9e43463d5a
commit
d5e3fc275e
1 changed files with 4 additions and 0 deletions
|
@ -993,6 +993,8 @@ int __get_mtd_device(struct mtd_info *mtd)
|
|||
}
|
||||
}
|
||||
|
||||
master->usecount++;
|
||||
|
||||
while (mtd->parent) {
|
||||
mtd->usecount++;
|
||||
mtd = mtd->parent;
|
||||
|
@ -1059,6 +1061,8 @@ void __put_mtd_device(struct mtd_info *mtd)
|
|||
mtd = mtd->parent;
|
||||
}
|
||||
|
||||
master->usecount--;
|
||||
|
||||
if (master->_put_device)
|
||||
master->_put_device(master);
|
||||
|
||||
|
|
Loading…
Reference in a new issue