Skip to contentSkip to conversation

mtd: ubi: Put MTD device after it is not used

PATCH In review Alexander Vickberg 2 participants 3 messages Apr 10, 2025 – May 5, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: ubi: Put MTD device after it is not used

The MTD device reference is dropped via put_mtd_device, however its field ->index is read and passed to ubi_msg. To fix this, the patch moves the reference dropping after calling ubi_msg.

Upstream Linux commit: b95f83ab762dd6211351b9140f99f43644076ca8

---
 drivers/mtd/ubi/build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/ubi/build.c +1 -1
index 50e43928af0..4881287dd6b 100644
@@ -1152,10 +1152,10 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
 	ubi_wl_close(ubi);
 	ubi_free_internal_volumes(ubi);
 	vfree(ubi->vtbl);
-	put_mtd_device(ubi->mtd);
 	vfree(ubi->peb_buf);
 	vfree(ubi->fm_buf);
 	ubi_msg(ubi, "mtd%d is detached", ubi->mtd->index);
+	put_mtd_device(ubi->mtd);
 	put_device(&ubi->dev);
 	return 0;
 }
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw

Hello Alexander,

Quoted 8 lines · Alexander Vickberg

The MTD device reference is dropped via put_mtd_device, however its field ->index is read and passed to ubi_msg. To fix this, the patch moves the reference dropping after calling ubi_msg.

Quoted 6 lines

Upstream Linux commit: b95f83ab762dd6211351b9140f99f43644076ca8

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

Thanks!

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]
#2 lore raw

Hello Alexander,

Quoted 13 lines · Heiko Schocher

Hello Alexander,

Quoted 10 lines · Alexander Vickberg

The MTD device reference is dropped via put_mtd_device, however its field ->index is read and passed to ubi_msg. To fix this, the patch moves the reference dropping after calling ubi_msg.

Upstream Linux commit: b95f83ab762dd6211351b9140f99f43644076ca8

Quoted 8 lines
Quoted 4 lines

---
  drivers/mtd/ubi/build.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks!

Applied to u-boot-ubi master

Thanks!

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]