Skip to content

Commit 1ca7141

Browse files
richardweinbergermiquelraynal
authored andcommitted
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: 46b5889 ("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
1 parent 18b9c94 commit 1ca7141

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/mtd/mtdcore.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,8 @@ int __get_mtd_device(struct mtd_info *mtd)
993993
}
994994
}
995995

996+
master->usecount++;
997+
996998
while (mtd->parent) {
997999
mtd->usecount++;
9981000
mtd = mtd->parent;
@@ -1059,6 +1061,8 @@ void __put_mtd_device(struct mtd_info *mtd)
10591061
mtd = mtd->parent;
10601062
}
10611063

1064+
master->usecount--;
1065+
10621066
if (master->_put_device)
10631067
master->_put_device(master);
10641068

0 commit comments

Comments
 (0)