[PATCH 5.10] mtd: core: call _get_device() with the master MTD

From: Mikhail Dmitrichenko

Date: Mon Nov 02 2026 - 04:55:07 EST


From: Karl Mehltretter <kmehltretter@xxxxxxxxx>

commit 12b31d1acd20b3185bb5f0748db0cf6874c8e9d1 upstream.

__get_mtd_device() calls the master's _get_device() callback with mtd,
which may be a partition. __put_mtd_device() passes the master.

This breaks gluebi partitions because gluebi_get_device() uses
container_of() and therefore requires the master MTD. Pass the master
to _get_device(), matching _put_device().

Fixes: 46b5889cc2c5 ("mtd: implement proper partition handling")
Assisted-by: Codex:gpt-5.6-sol
Signed-off-by: Karl Mehltretter <kmehltretter@xxxxxxxxx>
Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
[ mdmitrichenko: Keep the existing try_module_get()/module_put() error
path. 5.10 predates commit 79c4a5625021 ("mtd: call external _get and
_put in right order"). ]
Signed-off-by: Mikhail Dmitrichenko <mdmitrichenko@xxxxxxxxxxxxx>
---
Backport fix for CVE-2026-98833

drivers/mtd/mtdcore.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index b2d88ff90e93..d960d4ed2e5b 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -990,7 +990,7 @@ int __get_mtd_device(struct mtd_info *mtd)
return -ENODEV;

if (master->_get_device) {
- err = master->_get_device(mtd);
+ err = master->_get_device(master);

if (err) {
module_put(master->owner);
--
2.43.0