Commit 1ca71415 authored by Richard Weinberger's avatar Richard Weinberger Committed by Miquel Raynal

mtd: core: Fix refcounting for unpartitioned MTDs

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: default avatarRichard Weinberger <richard@nod.at>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20201206202220.27290-1-richard@nod.at
parent 18b9c940
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment