diff options
author | Richard Weinberger <richard@nod.at> | 2020-12-06 23:22:20 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-12-30 13:54:23 +0300 |
commit | d5e3fc275ea1f0f67f3b713cc866eb3248ae4080 (patch) | |
tree | 615ba6994665fa3463f96502c62688307dd0bf60 | |
parent | 9e43463d5a97b036579158bfcbacd7ba058c9d3b (diff) | |
download | linux-d5e3fc275ea1f0f67f3b713cc866eb3248ae4080.tar.xz |
mtd: core: Fix refcounting for unpartitioned MTDs
commit 1ca71415f075353974524e96ed175306d8a937a8 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: 46b5889cc2c5 ("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>
-rw-r--r-- | drivers/mtd/mtdcore.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index e9e163ae9d86..b07cbb0661fb 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -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); |